Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render MessagePack #37

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ jobs:
- name: Install Dependencies
run: |
go version
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/tinylib/msgp@latest

- name: Code Generation
run: go generate ./...
Expand Down Expand Up @@ -115,8 +114,7 @@ jobs:
- name: Install Dependencies
run: |
go version
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/tinylib/msgp@latest

- name: Code Generation
run: go generate ./...
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/rotationalio/confire v1.1.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
github.com/tinylib/msgp v1.2.4
github.com/urfave/cli/v2 v2.27.5
)

Expand All @@ -19,6 +20,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -34,6 +36,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinylib/msgp v1.2.4 h1:yLFeUGostXXSGW5vxfT5dXG/qzkn4schv2I7at5+hVU=
github.com/tinylib/msgp v1.2.4/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
Expand Down
31 changes: 22 additions & 9 deletions pkg/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package api

import "context"

//go:generate msgp

//===========================================================================
// Service Interface
//===========================================================================
Expand All @@ -17,21 +19,32 @@ type Client interface {

// Reply contains standard fields that are used for generic API responses and errors.
type Reply struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
ErrorDetail ErrorDetail `json:"errors,omitempty"`
Success bool `json:"success" msg:"success"`
Error string `json:"error,omitempty" msg:"error,omitempty"`
ErrorDetail ErrorDetail `json:"errors,omitempty" msg:"errors,omitempty"`
}

// Returned on status requests.
type StatusReply struct {
Status string `json:"status"`
Uptime string `json:"uptime,omitempty"`
Version string `json:"version,omitempty"`
Status string `json:"status" msg:"status"`
Uptime string `json:"uptime,omitempty" msg:"uptime,omitempty"`
Version string `json:"version,omitempty" msg:"version,omitempty"`
}

// PageQuery manages paginated list requests.
type PageQuery struct {
PageSize int `json:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
NextPageToken string `json:"next_page_token,omitempty" url:"next_page_token,omitempty" form:"next_page_token"`
PrevPageToken string `json:"prev_page_token,omitempty" url:"prev_page_token,omitempty" form:"prev_page_token"`
PageSize int `json:"page_size,omitempty" msg:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
NextPageToken string `json:"next_page_token,omitempty" msg:"next_page_token,omitempty" url:"next_page_token,omitempty" form:"next_page_token"`
PrevPageToken string `json:"prev_page_token,omitempty" msg:"prev_page_token,omitempty" url:"prev_page_token,omitempty" form:"prev_page_token"`
}

//===========================================================================
// Detail Error
//===========================================================================

type ErrorDetail []*DetailError

type DetailError struct {
Field string `json:"field" msg:"field"`
Error string `json:"error" msg:"error"`
}
Loading
Loading