Skip to content

Commit

Permalink
wip: transaction endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MintzyG committed Feb 22, 2024
1 parent a2783e6 commit 5d5adfd
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ module github.com/cciuenf/rinha

go 1.22.0

require github.com/labstack/echo/v4 v4.11.4

require (
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/labstack/echo/v4 v4.11.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/zoedsoupe/exo v0.2.3 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/zoedsoupe/exo v0.2.3 h1:HQzbuoWgJ9gnmX0VHd54ER9xzkyCBi+IwIQuhLAZBNk=
github.com/zoedsoupe/exo v0.2.3/go.mod h1:IWy7Y2ciTza+iC9ssK+VzqsdfWl4ZRHtvrJ5+y+T1TE=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
Expand Down
8 changes: 8 additions & 0 deletions internal/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package internal

type Client struct {
ID int
Name string
MaxLimit int
Balance int
}
37 changes: 37 additions & 0 deletions internal/transaction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package internal

import (
"errors"
"time"

. "github.com/zoedsoupe/exo/changeset"
)

type Transaction struct {
ID int
Value int
CustomerID int
Type [1]string
Description [10]string
CreatedAt time.Time
}

var transactions []Transaction

var client = [5]Client{
{1, "A", 1000 * 100, 0},
{2, "B", 800 * 100, 0},
{3, "C", 10000 * 100, 0},
{4, "D", 100000 * 100, 0},
{5, "E", 5000 * 100, 0},
}

func MakeTransaction(ID int, Value map[string]interface{}) (Transaction, error) {
var t Transaction
if ID < 1 || ID > 5 {
return t, errors.New("ID não exitse")
}

c := Cast[Transaction](Value)

}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"flag"
"net/http"

. "github.com/cciuenf/rinha/internal"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
Expand Down
Binary file added rinha
Binary file not shown.

0 comments on commit 5d5adfd

Please sign in to comment.