diff --git a/cmd/cache/main.go b/cmd/cache/main.go index 2217d6fb077101a7922ab2d9db3d99fcc8606806..0db3723ab09cb4cf45928bcbffbdd264324875e6 100644 --- a/cmd/cache/main.go +++ b/cmd/cache/main.go @@ -14,12 +14,16 @@ import ( goa "goa.design/goa/v3/pkg" "golang.org/x/sync/errgroup" + goacache "code.vereign.com/gaiax/tsa/cache/gen/cache" goahealth "code.vereign.com/gaiax/tsa/cache/gen/health" + goacachesrv "code.vereign.com/gaiax/tsa/cache/gen/http/cache/server" goahealthsrv "code.vereign.com/gaiax/tsa/cache/gen/http/health/server" goaopenapisrv "code.vereign.com/gaiax/tsa/cache/gen/http/openapi/server" "code.vereign.com/gaiax/tsa/cache/gen/openapi" + "code.vereign.com/gaiax/tsa/cache/internal/clients/redis" "code.vereign.com/gaiax/tsa/cache/internal/config" "code.vereign.com/gaiax/tsa/cache/internal/service" + "code.vereign.com/gaiax/tsa/cache/internal/service/cache" "code.vereign.com/gaiax/tsa/cache/internal/service/health" "code.vereign.com/gaiax/tsa/golib/graceful" ) @@ -40,20 +44,27 @@ func main() { logger.Info("start cache service", zap.String("version", Version), zap.String("goa", goa.Version())) + // create redis client + redis := redis.New(cfg.Redis.Addr, cfg.Redis.User, cfg.Redis.Pass, cfg.Redis.DB, cfg.Redis.TTL) + // create services var ( + cacheSvc goacache.Service healthSvc goahealth.Service ) { + cacheSvc = cache.New(redis, logger) healthSvc = health.New() } // create endpoints var ( + cacheEndpoints *goacache.Endpoints healthEndpoints *goahealth.Endpoints openapiEndpoints *openapi.Endpoints ) { + cacheEndpoints = goacache.NewEndpoints(cacheSvc) healthEndpoints = goahealth.NewEndpoints(healthSvc) openapiEndpoints = openapi.NewEndpoints(nil) } @@ -72,15 +83,18 @@ func main() { mux := goahttp.NewMuxer() var ( + cacheServer *goacachesrv.Server healthServer *goahealthsrv.Server openapiServer *goaopenapisrv.Server ) { + cacheServer = goacachesrv.New(cacheEndpoints, mux, dec, enc, nil, errFormatter) healthServer = goahealthsrv.New(healthEndpoints, mux, dec, enc, nil, errFormatter) openapiServer = goaopenapisrv.New(openapiEndpoints, mux, dec, enc, nil, errFormatter, nil, nil) } // Configure the mux. + goacachesrv.Mount(mux, cacheServer) goahealthsrv.Mount(mux, healthServer) goaopenapisrv.Mount(mux, openapiServer) diff --git a/design/design.go b/design/design.go index 24898ec3e833d5870f75fea6d0649d6a1d241401..0617832a38b93fa17411bdfbb53bd60df6dd43c0 100644 --- a/design/design.go +++ b/design/design.go @@ -10,7 +10,7 @@ var _ = API("cache", func() { Description("Cache Server") Host("development", func() { Description("Local development server") - URI("http://localhost:8080") + URI("http://localhost:8083") }) }) }) @@ -37,6 +37,33 @@ var _ = Service("health", func() { }) }) +var _ = Service("cache", func() { + Description("Cache service allows storing and retrieving data from distributed cache.") + + Method("Get", func() { + Description("Get value from the cache. The result is a sequence of bytes which the client must decode.") + + Payload(CacheGetRequest) + Result(Bytes) + + HTTP(func() { + GET("/v1/cache") + + Header("key:x-cache-key", String, "Cache entry key", func() { + Example("did:web:example.com") + }) + Header("namespace:x-cache-namespace", String, "Cache entry namespace", func() { + Example("Login") + }) + Header("scope:x-cache-scope", String, "Cache entry scope", func() { + Example("administration") + }) + + Response(StatusOK) + }) + }) +}) + var _ = Service("openapi", func() { Description("The openapi service serves the OpenAPI(v3) definition.") Meta("swagger:generate", "false") diff --git a/design/types.go b/design/types.go new file mode 100644 index 0000000000000000000000000000000000000000..57789a4b12ab9bf0bfb4dd467668d950e784e2a6 --- /dev/null +++ b/design/types.go @@ -0,0 +1,11 @@ +// nolint:revive +package design + +import . "goa.design/goa/v3/dsl" + +var CacheGetRequest = Type("CacheGetRequest", func() { + Field(1, "key", String) + Field(2, "namespace", String) + Field(3, "scope", String) // Initial implementation with a single scope + Required("key", "namespace", "scope") +}) diff --git a/gen/cache/client.go b/gen/cache/client.go new file mode 100644 index 0000000000000000000000000000000000000000..ec6218557a4ad5ef34f1a76161238b1105677603 --- /dev/null +++ b/gen/cache/client.go @@ -0,0 +1,36 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache client +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package cache + +import ( + "context" + + goa "goa.design/goa/v3/pkg" +) + +// Client is the "cache" service client. +type Client struct { + GetEndpoint goa.Endpoint +} + +// NewClient initializes a "cache" service client given the endpoints. +func NewClient(get goa.Endpoint) *Client { + return &Client{ + GetEndpoint: get, + } +} + +// Get calls the "Get" endpoint of the "cache" service. +func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res []byte, err error) { + var ires interface{} + ires, err = c.GetEndpoint(ctx, p) + if err != nil { + return + } + return ires.([]byte), nil +} diff --git a/gen/cache/endpoints.go b/gen/cache/endpoints.go new file mode 100644 index 0000000000000000000000000000000000000000..4dfb7f41650a6bc82b6317a2aea05fba34d967b2 --- /dev/null +++ b/gen/cache/endpoints.go @@ -0,0 +1,40 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache endpoints +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package cache + +import ( + "context" + + goa "goa.design/goa/v3/pkg" +) + +// Endpoints wraps the "cache" service endpoints. +type Endpoints struct { + Get goa.Endpoint +} + +// NewEndpoints wraps the methods of the "cache" service with endpoints. +func NewEndpoints(s Service) *Endpoints { + return &Endpoints{ + Get: NewGetEndpoint(s), + } +} + +// Use applies the given middleware to all the "cache" service endpoints. +func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { + e.Get = m(e.Get) +} + +// NewGetEndpoint returns an endpoint function that calls the method "Get" of +// service "cache". +func NewGetEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req interface{}) (interface{}, error) { + p := req.(*CacheGetRequest) + return s.Get(ctx, p) + } +} diff --git a/gen/cache/service.go b/gen/cache/service.go new file mode 100644 index 0000000000000000000000000000000000000000..089bd94d2623488893a2a0a9a7c2763957b84a0b --- /dev/null +++ b/gen/cache/service.go @@ -0,0 +1,36 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache service +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package cache + +import ( + "context" +) + +// Cache service allows storing and retrieving data from distributed cache. +type Service interface { + // Get value from the cache. The result is a sequence of bytes which the client + // must decode. + Get(context.Context, *CacheGetRequest) (res []byte, err error) +} + +// ServiceName is the name of the service as defined in the design. This is the +// same value that is set in the endpoint request contexts under the ServiceKey +// key. +const ServiceName = "cache" + +// MethodNames lists the service method names as defined in the design. These +// are the same values that are set in the endpoint request contexts under the +// MethodKey key. +var MethodNames = [1]string{"Get"} + +// CacheGetRequest is the payload type of the cache service Get method. +type CacheGetRequest struct { + Key string + Namespace string + Scope string +} diff --git a/gen/http/cache/client/cli.go b/gen/http/cache/client/cli.go new file mode 100644 index 0000000000000000000000000000000000000000..102424b710f74365e6125b64830218de30980a04 --- /dev/null +++ b/gen/http/cache/client/cli.go @@ -0,0 +1,34 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP client CLI support package +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package client + +import ( + cache "code.vereign.com/gaiax/tsa/cache/gen/cache" +) + +// BuildGetPayload builds the payload for the cache Get endpoint from CLI flags. +func BuildGetPayload(cacheGetKey string, cacheGetNamespace string, cacheGetScope string) (*cache.CacheGetRequest, error) { + var key string + { + key = cacheGetKey + } + var namespace string + { + namespace = cacheGetNamespace + } + var scope string + { + scope = cacheGetScope + } + v := &cache.CacheGetRequest{} + v.Key = key + v.Namespace = namespace + v.Scope = scope + + return v, nil +} diff --git a/gen/http/cache/client/client.go b/gen/http/cache/client/client.go new file mode 100644 index 0000000000000000000000000000000000000000..a909cf4774e21ad7b49f24881b0b1e2d4321f37b --- /dev/null +++ b/gen/http/cache/client/client.go @@ -0,0 +1,74 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache client HTTP transport +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package client + +import ( + "context" + "net/http" + + goahttp "goa.design/goa/v3/http" + goa "goa.design/goa/v3/pkg" +) + +// Client lists the cache service endpoint HTTP clients. +type Client struct { + // Get Doer is the HTTP client used to make requests to the Get endpoint. + GetDoer goahttp.Doer + + // RestoreResponseBody controls whether the response bodies are reset after + // decoding so they can be read again. + RestoreResponseBody bool + + scheme string + host string + encoder func(*http.Request) goahttp.Encoder + decoder func(*http.Response) goahttp.Decoder +} + +// NewClient instantiates HTTP clients for all the cache service servers. +func NewClient( + scheme string, + host string, + doer goahttp.Doer, + enc func(*http.Request) goahttp.Encoder, + dec func(*http.Response) goahttp.Decoder, + restoreBody bool, +) *Client { + return &Client{ + GetDoer: doer, + RestoreResponseBody: restoreBody, + scheme: scheme, + host: host, + decoder: dec, + encoder: enc, + } +} + +// Get returns an endpoint that makes HTTP requests to the cache service Get +// server. +func (c *Client) Get() goa.Endpoint { + var ( + encodeRequest = EncodeGetRequest(c.encoder) + decodeResponse = DecodeGetResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v interface{}) (interface{}, error) { + req, err := c.BuildGetRequest(ctx, v) + if err != nil { + return nil, err + } + err = encodeRequest(req, v) + if err != nil { + return nil, err + } + resp, err := c.GetDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("cache", "Get", err) + } + return decodeResponse(resp) + } +} diff --git a/gen/http/cache/client/encode_decode.go b/gen/http/cache/client/encode_decode.go new file mode 100644 index 0000000000000000000000000000000000000000..dd4550d9b4b97277842a3b9a182c872796d6ed01 --- /dev/null +++ b/gen/http/cache/client/encode_decode.go @@ -0,0 +1,93 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP client encoders and decoders +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package client + +import ( + "bytes" + "context" + "io/ioutil" + "net/http" + "net/url" + + cache "code.vereign.com/gaiax/tsa/cache/gen/cache" + goahttp "goa.design/goa/v3/http" +) + +// BuildGetRequest instantiates a HTTP request object with method and path set +// to call the "cache" service "Get" endpoint +func (c *Client) BuildGetRequest(ctx context.Context, v interface{}) (*http.Request, error) { + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: GetCachePath()} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("cache", "Get", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// EncodeGetRequest returns an encoder for requests sent to the cache Get +// server. +func EncodeGetRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Request, interface{}) error { + return func(req *http.Request, v interface{}) error { + p, ok := v.(*cache.CacheGetRequest) + if !ok { + return goahttp.ErrInvalidType("cache", "Get", "*cache.CacheGetRequest", v) + } + { + head := p.Key + req.Header.Set("x-cache-key", head) + } + { + head := p.Namespace + req.Header.Set("x-cache-namespace", head) + } + { + head := p.Scope + req.Header.Set("x-cache-scope", head) + } + return nil + } +} + +// DecodeGetResponse returns a decoder for responses returned by the cache Get +// endpoint. restoreBody controls whether the response body should be restored +// after having been read. +func DecodeGetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (interface{}, error) { + return func(resp *http.Response) (interface{}, error) { + if restoreBody { + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body []byte + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("cache", "Get", err) + } + return body, nil + default: + body, _ := ioutil.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("cache", "Get", resp.StatusCode, string(body)) + } + } +} diff --git a/gen/http/cache/client/paths.go b/gen/http/cache/client/paths.go new file mode 100644 index 0000000000000000000000000000000000000000..d4e85ee6fa5552f06361e65105ef5bea446e5753 --- /dev/null +++ b/gen/http/cache/client/paths.go @@ -0,0 +1,13 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// HTTP request path constructors for the cache service. +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package client + +// GetCachePath returns the URL path to the cache service Get HTTP endpoint. +func GetCachePath() string { + return "/v1/cache" +} diff --git a/gen/http/cache/client/types.go b/gen/http/cache/client/types.go new file mode 100644 index 0000000000000000000000000000000000000000..1103c0d8179848a2aeb90e6176dce16fc83efa31 --- /dev/null +++ b/gen/http/cache/client/types.go @@ -0,0 +1,8 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP client types +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package client diff --git a/gen/http/cache/server/encode_decode.go b/gen/http/cache/server/encode_decode.go new file mode 100644 index 0000000000000000000000000000000000000000..6e8629d2e7494d5e077d13533ad55a83d966660f --- /dev/null +++ b/gen/http/cache/server/encode_decode.go @@ -0,0 +1,59 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP server encoders and decoders +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package server + +import ( + "context" + "net/http" + + goahttp "goa.design/goa/v3/http" + goa "goa.design/goa/v3/pkg" +) + +// EncodeGetResponse returns an encoder for responses returned by the cache Get +// endpoint. +func EncodeGetResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error { + return func(ctx context.Context, w http.ResponseWriter, v interface{}) error { + res, _ := v.([]byte) + enc := encoder(ctx, w) + body := res + w.WriteHeader(http.StatusOK) + return enc.Encode(body) + } +} + +// DecodeGetRequest returns a decoder for requests sent to the cache Get +// endpoint. +func DecodeGetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error) { + return func(r *http.Request) (interface{}, error) { + var ( + key string + namespace string + scope string + err error + ) + key = r.Header.Get("x-cache-key") + if key == "" { + err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-key", "header")) + } + namespace = r.Header.Get("x-cache-namespace") + if namespace == "" { + err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-namespace", "header")) + } + scope = r.Header.Get("x-cache-scope") + if scope == "" { + err = goa.MergeErrors(err, goa.MissingFieldError("x-cache-scope", "header")) + } + if err != nil { + return nil, err + } + payload := NewGetCacheGetRequest(key, namespace, scope) + + return payload, nil + } +} diff --git a/gen/http/cache/server/paths.go b/gen/http/cache/server/paths.go new file mode 100644 index 0000000000000000000000000000000000000000..656155750cbb8e8932366cf94bde88f3d5e97d6f --- /dev/null +++ b/gen/http/cache/server/paths.go @@ -0,0 +1,13 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// HTTP request path constructors for the cache service. +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package server + +// GetCachePath returns the URL path to the cache service Get HTTP endpoint. +func GetCachePath() string { + return "/v1/cache" +} diff --git a/gen/http/cache/server/server.go b/gen/http/cache/server/server.go new file mode 100644 index 0000000000000000000000000000000000000000..63e8e6f0139c65f080770c08f884366d149a90b3 --- /dev/null +++ b/gen/http/cache/server/server.go @@ -0,0 +1,131 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP server +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package server + +import ( + "context" + "net/http" + + cache "code.vereign.com/gaiax/tsa/cache/gen/cache" + goahttp "goa.design/goa/v3/http" + goa "goa.design/goa/v3/pkg" +) + +// Server lists the cache service endpoint HTTP handlers. +type Server struct { + Mounts []*MountPoint + Get http.Handler +} + +// ErrorNamer is an interface implemented by generated error structs that +// exposes the name of the error as defined in the design. +type ErrorNamer interface { + ErrorName() string +} + +// MountPoint holds information about the mounted endpoints. +type MountPoint struct { + // Method is the name of the service method served by the mounted HTTP handler. + Method string + // Verb is the HTTP method used to match requests to the mounted handler. + Verb string + // Pattern is the HTTP request path pattern used to match requests to the + // mounted handler. + Pattern string +} + +// New instantiates HTTP handlers for all the cache service endpoints using the +// provided encoder and decoder. The handlers are mounted on the given mux +// using the HTTP verb and path defined in the design. errhandler is called +// whenever a response fails to be encoded. formatter is used to format errors +// returned by the service methods prior to encoding. Both errhandler and +// formatter are optional and can be nil. +func New( + e *cache.Endpoints, + mux goahttp.Muxer, + decoder func(*http.Request) goahttp.Decoder, + encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, + errhandler func(context.Context, http.ResponseWriter, error), + formatter func(err error) goahttp.Statuser, +) *Server { + return &Server{ + Mounts: []*MountPoint{ + {"Get", "GET", "/v1/cache"}, + }, + Get: NewGetHandler(e.Get, mux, decoder, encoder, errhandler, formatter), + } +} + +// Service returns the name of the service served. +func (s *Server) Service() string { return "cache" } + +// Use wraps the server handlers with the given middleware. +func (s *Server) Use(m func(http.Handler) http.Handler) { + s.Get = m(s.Get) +} + +// Mount configures the mux to serve the cache endpoints. +func Mount(mux goahttp.Muxer, h *Server) { + MountGetHandler(mux, h.Get) +} + +// Mount configures the mux to serve the cache endpoints. +func (s *Server) Mount(mux goahttp.Muxer) { + Mount(mux, s) +} + +// MountGetHandler configures the mux to serve the "cache" service "Get" +// endpoint. +func MountGetHandler(mux goahttp.Muxer, h http.Handler) { + f, ok := h.(http.HandlerFunc) + if !ok { + f = func(w http.ResponseWriter, r *http.Request) { + h.ServeHTTP(w, r) + } + } + mux.Handle("GET", "/v1/cache", f) +} + +// NewGetHandler creates a HTTP handler which loads the HTTP request and calls +// the "cache" service "Get" endpoint. +func NewGetHandler( + endpoint goa.Endpoint, + mux goahttp.Muxer, + decoder func(*http.Request) goahttp.Decoder, + encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, + errhandler func(context.Context, http.ResponseWriter, error), + formatter func(err error) goahttp.Statuser, +) http.Handler { + var ( + decodeRequest = DecodeGetRequest(mux, decoder) + encodeResponse = EncodeGetResponse(encoder) + encodeError = goahttp.ErrorEncoder(encoder, formatter) + ) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := context.WithValue(r.Context(), goahttp.AcceptTypeKey, r.Header.Get("Accept")) + ctx = context.WithValue(ctx, goa.MethodKey, "Get") + ctx = context.WithValue(ctx, goa.ServiceKey, "cache") + payload, err := decodeRequest(r) + if err != nil { + if err := encodeError(ctx, w, err); err != nil { + errhandler(ctx, w, err) + } + return + } + res, err := endpoint(ctx, payload) + if err != nil { + if err := encodeError(ctx, w, err); err != nil { + errhandler(ctx, w, err) + } + return + } + if err := encodeResponse(ctx, w, res); err != nil { + errhandler(ctx, w, err) + } + }) +} diff --git a/gen/http/cache/server/types.go b/gen/http/cache/server/types.go new file mode 100644 index 0000000000000000000000000000000000000000..4585d80628f45910bd241d0caacce974fb9766fd --- /dev/null +++ b/gen/http/cache/server/types.go @@ -0,0 +1,22 @@ +// Code generated by goa v3.7.0, DO NOT EDIT. +// +// cache HTTP server types +// +// Command: +// $ goa gen code.vereign.com/gaiax/tsa/cache/design + +package server + +import ( + cache "code.vereign.com/gaiax/tsa/cache/gen/cache" +) + +// NewGetCacheGetRequest builds a cache service Get endpoint payload. +func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.CacheGetRequest { + v := &cache.CacheGetRequest{} + v.Key = key + v.Namespace = namespace + v.Scope = scope + + return v +} diff --git a/gen/http/cli/cache/cli.go b/gen/http/cli/cache/cli.go index eb43bef11990364416b90a171b5c20ffbfe2066d..2bfecddeacdbcbb0bd07454c0527db1669dc680a 100644 --- a/gen/http/cli/cache/cli.go +++ b/gen/http/cli/cache/cli.go @@ -13,6 +13,7 @@ import ( "net/http" "os" + cachec "code.vereign.com/gaiax/tsa/cache/gen/http/cache/client" healthc "code.vereign.com/gaiax/tsa/cache/gen/http/health/client" goahttp "goa.design/goa/v3/http" goa "goa.design/goa/v3/pkg" @@ -24,12 +25,14 @@ import ( // func UsageCommands() string { return `health (liveness|readiness) +cache get ` } // UsageExamples produces an example of a valid invocation of the CLI tool. func UsageExamples() string { return os.Args[0] + ` health liveness` + "\n" + + os.Args[0] + ` cache get --key "Officiis fuga architecto cum." --namespace "Sint adipisci." --scope "Debitis id reprehenderit incidunt necessitatibus assumenda."` + "\n" + "" } @@ -48,11 +51,21 @@ func ParseEndpoint( healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError) healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError) + + cacheFlags = flag.NewFlagSet("cache", flag.ContinueOnError) + + cacheGetFlags = flag.NewFlagSet("get", flag.ExitOnError) + cacheGetKeyFlag = cacheGetFlags.String("key", "REQUIRED", "") + cacheGetNamespaceFlag = cacheGetFlags.String("namespace", "REQUIRED", "") + cacheGetScopeFlag = cacheGetFlags.String("scope", "REQUIRED", "") ) healthFlags.Usage = healthUsage healthLivenessFlags.Usage = healthLivenessUsage healthReadinessFlags.Usage = healthReadinessUsage + cacheFlags.Usage = cacheUsage + cacheGetFlags.Usage = cacheGetUsage + if err := flag.CommandLine.Parse(os.Args[1:]); err != nil { return nil, nil, err } @@ -70,6 +83,8 @@ func ParseEndpoint( switch svcn { case "health": svcf = healthFlags + case "cache": + svcf = cacheFlags default: return nil, nil, fmt.Errorf("unknown service %q", svcn) } @@ -95,6 +110,13 @@ func ParseEndpoint( } + case "cache": + switch epn { + case "get": + epf = cacheGetFlags + + } + } } if epf == nil { @@ -125,6 +147,13 @@ func ParseEndpoint( endpoint = c.Readiness() data = nil } + case "cache": + c := cachec.NewClient(scheme, host, doer, enc, dec, restore) + switch epn { + case "get": + endpoint = c.Get() + data, err = cachec.BuildGetPayload(*cacheGetKeyFlag, *cacheGetNamespaceFlag, *cacheGetScopeFlag) + } } } if err != nil { @@ -167,3 +196,29 @@ Example: %[1]s health readiness `, os.Args[0]) } + +// cacheUsage displays the usage of the cache command and its subcommands. +func cacheUsage() { + fmt.Fprintf(os.Stderr, `Cache service allows storing and retrieving data from distributed cache. +Usage: + %[1]s [globalflags] cache COMMAND [flags] + +COMMAND: + get: Get value from the cache. The result is a sequence of bytes which the client must decode. + +Additional help: + %[1]s cache COMMAND --help +`, os.Args[0]) +} +func cacheGetUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] cache get -key STRING -namespace STRING -scope STRING + +Get value from the cache. The result is a sequence of bytes which the client must decode. + -key STRING: + -namespace STRING: + -scope STRING: + +Example: + %[1]s cache get --key "Officiis fuga architecto cum." --namespace "Sint adipisci." --scope "Debitis id reprehenderit incidunt necessitatibus assumenda." +`, os.Args[0]) +} diff --git a/gen/http/openapi.json b/gen/http/openapi.json index 8c91c6fccacbde7e5040505856382d7840616b5c..b77a470aa4c05f88e90ef116416482555f7a5c90 100644 --- a/gen/http/openapi.json +++ b/gen/http/openapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8080","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"byte"}}},"schemes":["http"]}}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index c50746b2c0567940ad00eb98af2331a8fda26af2..5043265f7fa571f22f8a8f96b303296e161d0cdd 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -3,7 +3,7 @@ info: title: Cache Service description: The cache service exposes interface for working with Redis. version: "" -host: localhost:8080 +host: localhost:8083 consumes: - application/json - application/xml @@ -35,3 +35,35 @@ paths: description: OK response. schemes: - http + /v1/cache: + get: + tags: + - cache + summary: Get cache + description: Get value from the cache. The result is a sequence of bytes which + the client must decode. + operationId: cache#Get + parameters: + - name: x-cache-key + in: header + description: Cache entry key + required: true + type: string + - name: x-cache-namespace + in: header + description: Cache entry namespace + required: true + type: string + - name: x-cache-scope + in: header + description: Cache entry scope + required: true + type: string + responses: + "200": + description: OK response. + schema: + type: string + format: byte + schemes: + - http diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 2adcd5c09ec47fdc81bdb2f93cfc9dc61ac909e3..be3f9a4d1f1018196f1bb8c204da2f91a9434473 100644 --- a/gen/http/openapi3.json +++ b/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8080","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"UmVwdWRpYW5kYWUgZW9zIGNvbnNlcXVhdHVyIHNpbnQgZG9sb3J1bSBvY2NhZWNhdGku","format":"binary"},"example":"Vm9sdXB0YXR1bSBtb2RpIHRlbmV0dXIgdGVtcG9yZSBxdWlhIGVzdCByYXRpb25lLg=="}}}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 430bf22afb8f88b6e2477c51403eb23952daf74c..7fa181f0598cfd836cc793396662672f5d9f5776 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -4,7 +4,7 @@ info: description: The cache service exposes interface for working with Redis. version: "1.0" servers: -- url: http://localhost:8080 +- url: http://localhost:8083 description: Cache Server paths: /liveness: @@ -25,7 +25,158 @@ paths: responses: "200": description: OK response. + /v1/cache: + get: + tags: + - cache + summary: Get cache + description: Get value from the cache. The result is a sequence of bytes which + the client must decode. + operationId: cache#Get + parameters: + - name: x-cache-key + in: header + description: Cache entry key + allowEmptyValue: true + required: true + schema: + type: string + description: Cache entry key + example: did:web:example.com + example: did:web:example.com + - name: x-cache-namespace + in: header + description: Cache entry namespace + allowEmptyValue: true + required: true + schema: + type: string + description: Cache entry namespace + example: Login + example: Login + - name: x-cache-scope + in: header + description: Cache entry scope + allowEmptyValue: true + required: true + schema: + type: string + description: Cache entry scope + example: administration + example: administration + responses: + "200": + description: OK response. + content: + application/json: + schema: + type: string + example: + - 82 + - 101 + - 112 + - 117 + - 100 + - 105 + - 97 + - 110 + - 100 + - 97 + - 101 + - 32 + - 101 + - 111 + - 115 + - 32 + - 99 + - 111 + - 110 + - 115 + - 101 + - 113 + - 117 + - 97 + - 116 + - 117 + - 114 + - 32 + - 115 + - 105 + - 110 + - 116 + - 32 + - 100 + - 111 + - 108 + - 111 + - 114 + - 117 + - 109 + - 32 + - 111 + - 99 + - 99 + - 97 + - 101 + - 99 + - 97 + - 116 + - 105 + - 46 + format: binary + example: + - 86 + - 111 + - 108 + - 117 + - 112 + - 116 + - 97 + - 116 + - 117 + - 109 + - 32 + - 109 + - 111 + - 100 + - 105 + - 32 + - 116 + - 101 + - 110 + - 101 + - 116 + - 117 + - 114 + - 32 + - 116 + - 101 + - 109 + - 112 + - 111 + - 114 + - 101 + - 32 + - 113 + - 117 + - 105 + - 97 + - 32 + - 101 + - 115 + - 116 + - 32 + - 114 + - 97 + - 116 + - 105 + - 111 + - 110 + - 101 + - 46 components: {} tags: - name: health description: Health service provides health check endpoints. +- name: cache + description: Cache service allows storing and retrieving data from distributed cache. diff --git a/go.mod b/go.mod index acf6eebfa6c324902e1546a382063f88ac92a1dc..e454d03a8e3ef048190790a11f09abe40c2af08c 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( code.vereign.com/gaiax/tsa/golib v0.0.0-20220321093827-5fdf8f34aad9 + github.com/go-redis/redis/v8 v8.11.5 github.com/kelseyhightower/envconfig v1.4.0 go.uber.org/zap v1.21.0 goa.design/goa/v3 v3.7.0 @@ -11,6 +12,8 @@ require ( ) require ( + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 // indirect github.com/dimfeld/httptreemux/v5 v5.4.0 // indirect github.com/google/uuid v1.3.0 // indirect diff --git a/go.sum b/go.sum index a585769adc8ea031ac20128c27bc36566cb4411b..5fb6c68f73fa4b030fbc627154504d2e96c82076 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -69,6 +71,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 h1:MGKhKyiYrvMDZsmLR/+RGffQSXwEkXgfLSA08qDn9AI= github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598/go.mod h1:0FpDmbrt36utu8jEmeU05dPC9AB5tsLYVVi+ZHfyuwI= github.com/dimfeld/httptreemux/v5 v5.4.0 h1:IiHYEjh+A7pYbhWyjmGnj5HZK6gpOOvyBXCJ+BE8/Gs= @@ -82,6 +86,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/getkin/kin-openapi v0.92.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -91,6 +97,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.13/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -153,6 +162,7 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -186,6 +196,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -231,6 +242,20 @@ github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJE github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -351,6 +376,7 @@ golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdx golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -373,6 +399,7 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -385,7 +412,9 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -413,6 +442,7 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cO golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -422,9 +452,11 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -445,6 +477,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -470,6 +503,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -521,6 +555,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -644,7 +679,10 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/clients/redis/client.go b/internal/clients/redis/client.go new file mode 100644 index 0000000000000000000000000000000000000000..84d5106ebd417ffbf82945259c2174fb0bb6abdc --- /dev/null +++ b/internal/clients/redis/client.go @@ -0,0 +1,43 @@ +package redis + +import ( + "context" + "time" + + "github.com/go-redis/redis/v8" + + "code.vereign.com/gaiax/tsa/golib/errors" +) + +type Client struct { + rdb *redis.Client + defaultTTL time.Duration +} + +func New(addr, user, pass string, db int, defaultTTL time.Duration) *Client { + rdb := redis.NewClient(&redis.Options{ + Addr: addr, + Username: user, + Password: pass, + DB: db, + DialTimeout: 10 * time.Second, + ReadTimeout: 5 * time.Second, + WriteTimeout: 5 * time.Second, + }) + + return &Client{ + rdb: rdb, + defaultTTL: defaultTTL, + } +} + +func (c *Client) Get(ctx context.Context, key string) ([]byte, error) { + result := c.rdb.Get(ctx, key) + if result.Err() != nil { + if result.Err() == redis.Nil { + return nil, errors.New(errors.NotFound) + } + return nil, result.Err() + } + return []byte(result.Val()), nil +} diff --git a/internal/config/config.go b/internal/config/config.go index bdb25c11fa2d8aa3c2ea8c19adb6d93c15d65799..cdcfee1f3b5454ec096f6e787dd4a5552dd53fd4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,8 @@ package config import "time" type Config struct { - HTTP httpConfig + HTTP httpConfig + Redis redisConfig LogLevel string `envconfig:"LOG_LEVEL" default:"INFO"` } @@ -15,3 +16,11 @@ type httpConfig struct { ReadTimeout time.Duration `envconfig:"HTTP_READ_TIMEOUT" default:"10s"` WriteTimeout time.Duration `envconfig:"HTTP_WRITE_TIMEOUT" default:"10s"` } + +type redisConfig struct { + Addr string `envconfig:"REDIS_ADDR" required:"true"` + User string `envconfig:"REDIS_USER" required:"true"` + Pass string `envconfig:"REDIS_PASS" required:"true"` + DB int `envconfig:"REDIS_DB" default:"0"` + TTL time.Duration `envconfig:"REDIS_EXPIRATION"` // no default expiration, keys are set to live forever +} diff --git a/internal/service/cache/service.go b/internal/service/cache/service.go new file mode 100644 index 0000000000000000000000000000000000000000..0e3153a6a3ac0ed6a03720e9b617f22246b38847 --- /dev/null +++ b/internal/service/cache/service.go @@ -0,0 +1,52 @@ +package cache + +import ( + "context" + "fmt" + + "go.uber.org/zap" + + "code.vereign.com/gaiax/tsa/cache/gen/cache" + "code.vereign.com/gaiax/tsa/golib/errors" +) + +type Cache interface { + Get(ctx context.Context, key string) ([]byte, error) +} + +type Service struct { + cache Cache + logger *zap.Logger +} + +func New(cache Cache, logger *zap.Logger) *Service { + return &Service{ + cache: cache, + logger: logger, + } +} + +func (s *Service) Get(ctx context.Context, req *cache.CacheGetRequest) ([]byte, error) { + var operation = zap.String("operation", "get") + if req.Key == "" || req.Namespace == "" || req.Scope == "" { + s.logger.Error("bad request: missing key or namespace or scopes", operation) + return nil, errors.New(errors.BadRequest, "bad request") + } + + // create key from the input fields + key := makeCacheKey(req.Key, req.Namespace, req.Scope) + data, err := s.cache.Get(ctx, key) + if err != nil { + s.logger.Error("error getting value from cache", zap.String("key", key), zap.Error(err)) + if errors.Is(errors.NotFound, err) { + return nil, errors.New("key not found in cache", err) + } + return nil, errors.New("error getting value from cache", err) + } + + return data, nil +} + +func makeCacheKey(namespace, scope, key string) string { + return fmt.Sprintf("%s,%s,%s", namespace, scope, key) +} diff --git a/vendor/github.com/cespare/xxhash/v2/LICENSE.txt b/vendor/github.com/cespare/xxhash/v2/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..24b53065f40b5d7d277a64375956ec19cb2123c5 Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/LICENSE.txt differ diff --git a/vendor/github.com/cespare/xxhash/v2/README.md b/vendor/github.com/cespare/xxhash/v2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..792b4a60b346536061e65b9fbaeeb2475be4e3c1 Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/README.md differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash.go b/vendor/github.com/cespare/xxhash/v2/xxhash.go new file mode 100644 index 0000000000000000000000000000000000000000..15c835d5417c06d14182c50afc7c5b2ca0b45fce Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash.go differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go new file mode 100644 index 0000000000000000000000000000000000000000..ad14b807f4d96913a9c77366a61f075b188554cc Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s new file mode 100644 index 0000000000000000000000000000000000000000..be8db5bf796015120afa0748cf1c39f2acf4f576 Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_other.go b/vendor/github.com/cespare/xxhash/v2/xxhash_other.go new file mode 100644 index 0000000000000000000000000000000000000000..4a5a821603e5b8d876d07219882c5e127619f1a3 Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash_other.go differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go new file mode 100644 index 0000000000000000000000000000000000000000..fc9bea7a31f2b7cb8b9e6724735b4166eba2adc6 Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go differ diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go new file mode 100644 index 0000000000000000000000000000000000000000..376e0ca2e49745ecb087871d2e27afb4ed2d987d Binary files /dev/null and b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go differ diff --git a/vendor/github.com/dgryski/go-rendezvous/LICENSE b/vendor/github.com/dgryski/go-rendezvous/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..22080f736a41a6fb2287c3f0cf5c5b25345279a4 Binary files /dev/null and b/vendor/github.com/dgryski/go-rendezvous/LICENSE differ diff --git a/vendor/github.com/dgryski/go-rendezvous/rdv.go b/vendor/github.com/dgryski/go-rendezvous/rdv.go new file mode 100644 index 0000000000000000000000000000000000000000..7a6f8203c67810356a413b9f56abf30a0429de59 Binary files /dev/null and b/vendor/github.com/dgryski/go-rendezvous/rdv.go differ diff --git a/vendor/github.com/go-redis/redis/v8/.gitignore b/vendor/github.com/go-redis/redis/v8/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b975a7b4c3264a9876ac1df8ce6f44ac20b8c4ce Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/.gitignore differ diff --git a/vendor/github.com/go-redis/redis/v8/.golangci.yml b/vendor/github.com/go-redis/redis/v8/.golangci.yml new file mode 100644 index 0000000000000000000000000000000000000000..de514554a9cce0cd9acbdabf681e80e8a25cfe90 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/.golangci.yml differ diff --git a/vendor/github.com/go-redis/redis/v8/.prettierrc.yml b/vendor/github.com/go-redis/redis/v8/.prettierrc.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b7f044ad1f56bf1646588b9bd3f9715426c2906 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/.prettierrc.yml differ diff --git a/vendor/github.com/go-redis/redis/v8/CHANGELOG.md b/vendor/github.com/go-redis/redis/v8/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..195e51933866cc492cd66e007337d4a167e23b88 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/CHANGELOG.md differ diff --git a/vendor/github.com/go-redis/redis/v8/LICENSE b/vendor/github.com/go-redis/redis/v8/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..298bed9beaf7d43c0d2c464d6fb36dcec733b3bb Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/LICENSE differ diff --git a/vendor/github.com/go-redis/redis/v8/Makefile b/vendor/github.com/go-redis/redis/v8/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a4cfe0576e68c3485c7038c4af7debab5c0276cf Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/Makefile differ diff --git a/vendor/github.com/go-redis/redis/v8/README.md b/vendor/github.com/go-redis/redis/v8/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f3b6a018cb545dfa0ff4eeb309a17eee7340727a Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/README.md differ diff --git a/vendor/github.com/go-redis/redis/v8/RELEASING.md b/vendor/github.com/go-redis/redis/v8/RELEASING.md new file mode 100644 index 0000000000000000000000000000000000000000..1115db4e3e57c45499472abb4ff5a3219150226d Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/RELEASING.md differ diff --git a/vendor/github.com/go-redis/redis/v8/cluster.go b/vendor/github.com/go-redis/redis/v8/cluster.go new file mode 100644 index 0000000000000000000000000000000000000000..a54f2f37ed9cb532e48f63e92ad7bb6aaebafa7f Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/cluster.go differ diff --git a/vendor/github.com/go-redis/redis/v8/cluster_commands.go b/vendor/github.com/go-redis/redis/v8/cluster_commands.go new file mode 100644 index 0000000000000000000000000000000000000000..085bce83d5674eca293ccf186a4d506ad54fac04 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/cluster_commands.go differ diff --git a/vendor/github.com/go-redis/redis/v8/command.go b/vendor/github.com/go-redis/redis/v8/command.go new file mode 100644 index 0000000000000000000000000000000000000000..4bb12a85be43837c5b4c93666161f57842ed2c4b Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/command.go differ diff --git a/vendor/github.com/go-redis/redis/v8/commands.go b/vendor/github.com/go-redis/redis/v8/commands.go new file mode 100644 index 0000000000000000000000000000000000000000..bbfe089df166db9c1dda980a957a16d9c6f9ae44 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/commands.go differ diff --git a/vendor/github.com/go-redis/redis/v8/doc.go b/vendor/github.com/go-redis/redis/v8/doc.go new file mode 100644 index 0000000000000000000000000000000000000000..55262533a63dcccc159250a57f31bd9c9d25bdf8 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/doc.go differ diff --git a/vendor/github.com/go-redis/redis/v8/error.go b/vendor/github.com/go-redis/redis/v8/error.go new file mode 100644 index 0000000000000000000000000000000000000000..521594bbd0c939d077732130ccdff2a9c8366f75 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/error.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/arg.go b/vendor/github.com/go-redis/redis/v8/internal/arg.go new file mode 100644 index 0000000000000000000000000000000000000000..b97fa0d6851796b3e48a080e0b5b1f687557a906 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/arg.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/hashtag/hashtag.go b/vendor/github.com/go-redis/redis/v8/internal/hashtag/hashtag.go new file mode 100644 index 0000000000000000000000000000000000000000..b3a4f211e3369d3af22509ebf04b03e593a5fee0 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/hashtag/hashtag.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/hscan/hscan.go b/vendor/github.com/go-redis/redis/v8/internal/hscan/hscan.go new file mode 100644 index 0000000000000000000000000000000000000000..852c8bd525a7fe9c64746c5439caa830b4cd6e65 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/hscan/hscan.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/hscan/structmap.go b/vendor/github.com/go-redis/redis/v8/internal/hscan/structmap.go new file mode 100644 index 0000000000000000000000000000000000000000..6839412ba259da28d2ef53ea2e82098080d64a1d Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/hscan/structmap.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/internal.go b/vendor/github.com/go-redis/redis/v8/internal/internal.go new file mode 100644 index 0000000000000000000000000000000000000000..4a59c599be77d76687e7a7d591dbfda40ef7fb8a Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/internal.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/log.go b/vendor/github.com/go-redis/redis/v8/internal/log.go new file mode 100644 index 0000000000000000000000000000000000000000..c8b9213de48cdbeb5c5971b50f47a088e8fd72ed Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/log.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/once.go b/vendor/github.com/go-redis/redis/v8/internal/once.go new file mode 100644 index 0000000000000000000000000000000000000000..64f46272aedc1408c709066d591f8274bd34b9a6 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/once.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/pool/conn.go b/vendor/github.com/go-redis/redis/v8/internal/pool/conn.go new file mode 100644 index 0000000000000000000000000000000000000000..5661659865123d9cc64cdb1b72c9835181478a5d Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/pool/conn.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go b/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go new file mode 100644 index 0000000000000000000000000000000000000000..44a4e779dfae4531d91d1e0632091f6d607fab41 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/pool/pool_single.go b/vendor/github.com/go-redis/redis/v8/internal/pool/pool_single.go new file mode 100644 index 0000000000000000000000000000000000000000..5a3fde191bbbc90a57808a5466375a5e833095c7 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/pool/pool_single.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/pool/pool_sticky.go b/vendor/github.com/go-redis/redis/v8/internal/pool/pool_sticky.go new file mode 100644 index 0000000000000000000000000000000000000000..3adb99bc820f73f11f5b4ee306f800605e5ac59e Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/pool/pool_sticky.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/proto/reader.go b/vendor/github.com/go-redis/redis/v8/internal/proto/reader.go new file mode 100644 index 0000000000000000000000000000000000000000..0e6ca779b18984871279e8c5ddf272bb3e223533 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/proto/reader.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/proto/scan.go b/vendor/github.com/go-redis/redis/v8/internal/proto/scan.go new file mode 100644 index 0000000000000000000000000000000000000000..0e994765feed102597ddfcb7b610a7a1efbd5bd9 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/proto/scan.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/proto/writer.go b/vendor/github.com/go-redis/redis/v8/internal/proto/writer.go new file mode 100644 index 0000000000000000000000000000000000000000..c4260981ed14bea997b86f18d51825ef2c60e89a Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/proto/writer.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go b/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go new file mode 100644 index 0000000000000000000000000000000000000000..2edccba94fe88821e1d8e3750922fbd0b9817374 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/safe.go b/vendor/github.com/go-redis/redis/v8/internal/safe.go new file mode 100644 index 0000000000000000000000000000000000000000..fd2f43409472909eb539e73f92b70d74d5b9b2e8 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/safe.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/unsafe.go b/vendor/github.com/go-redis/redis/v8/internal/unsafe.go new file mode 100644 index 0000000000000000000000000000000000000000..9f2e418f7901993bcd990d1e62523eebee018440 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/unsafe.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/util.go b/vendor/github.com/go-redis/redis/v8/internal/util.go new file mode 100644 index 0000000000000000000000000000000000000000..e34a7f032620129337468474297c941798167883 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/util.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/util/safe.go b/vendor/github.com/go-redis/redis/v8/internal/util/safe.go new file mode 100644 index 0000000000000000000000000000000000000000..21307110bd544ee19414db435e47e32748e50e95 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/util/safe.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/util/strconv.go b/vendor/github.com/go-redis/redis/v8/internal/util/strconv.go new file mode 100644 index 0000000000000000000000000000000000000000..db5033802a958bfbd1c0590daf1d58e9b7bb663e Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/util/strconv.go differ diff --git a/vendor/github.com/go-redis/redis/v8/internal/util/unsafe.go b/vendor/github.com/go-redis/redis/v8/internal/util/unsafe.go new file mode 100644 index 0000000000000000000000000000000000000000..daa8d7692ae0cabb9447b57825853a746c5034b3 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/internal/util/unsafe.go differ diff --git a/vendor/github.com/go-redis/redis/v8/iterator.go b/vendor/github.com/go-redis/redis/v8/iterator.go new file mode 100644 index 0000000000000000000000000000000000000000..2f8bc2beda083563af654cbd1e7c06c94bb9766c Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/iterator.go differ diff --git a/vendor/github.com/go-redis/redis/v8/options.go b/vendor/github.com/go-redis/redis/v8/options.go new file mode 100644 index 0000000000000000000000000000000000000000..a4abe32c3a04e76984b6a07feca6a8d393acdb89 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/options.go differ diff --git a/vendor/github.com/go-redis/redis/v8/package.json b/vendor/github.com/go-redis/redis/v8/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e4ea4bb074c418c016bae3351c65450ff7f8a8eb Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/package.json differ diff --git a/vendor/github.com/go-redis/redis/v8/pipeline.go b/vendor/github.com/go-redis/redis/v8/pipeline.go new file mode 100644 index 0000000000000000000000000000000000000000..31bab971e63fd2f15db681347574053262303b37 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/pipeline.go differ diff --git a/vendor/github.com/go-redis/redis/v8/pubsub.go b/vendor/github.com/go-redis/redis/v8/pubsub.go new file mode 100644 index 0000000000000000000000000000000000000000..efc2354af0c547b99cc7a96f5c595f34609e9675 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/pubsub.go differ diff --git a/vendor/github.com/go-redis/redis/v8/redis.go b/vendor/github.com/go-redis/redis/v8/redis.go new file mode 100644 index 0000000000000000000000000000000000000000..bcf8a2a94bd064ae331a0a8dd2ede097752b03a8 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/redis.go differ diff --git a/vendor/github.com/go-redis/redis/v8/result.go b/vendor/github.com/go-redis/redis/v8/result.go new file mode 100644 index 0000000000000000000000000000000000000000..24cfd4994026363b2868afa9045f713e55fa60da Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/result.go differ diff --git a/vendor/github.com/go-redis/redis/v8/ring.go b/vendor/github.com/go-redis/redis/v8/ring.go new file mode 100644 index 0000000000000000000000000000000000000000..4df00fc857f532da2e7d77844d0f8ea4f31225ac Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/ring.go differ diff --git a/vendor/github.com/go-redis/redis/v8/script.go b/vendor/github.com/go-redis/redis/v8/script.go new file mode 100644 index 0000000000000000000000000000000000000000..5cab18d617c89f2bc30f75af765a5876b56331d6 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/script.go differ diff --git a/vendor/github.com/go-redis/redis/v8/sentinel.go b/vendor/github.com/go-redis/redis/v8/sentinel.go new file mode 100644 index 0000000000000000000000000000000000000000..ec6221dc83d4279ed92644209ca9fbfc92a77ef0 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/sentinel.go differ diff --git a/vendor/github.com/go-redis/redis/v8/tx.go b/vendor/github.com/go-redis/redis/v8/tx.go new file mode 100644 index 0000000000000000000000000000000000000000..8c9d87202aed7d2d7b2aa2efa0273c6f07258948 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/tx.go differ diff --git a/vendor/github.com/go-redis/redis/v8/universal.go b/vendor/github.com/go-redis/redis/v8/universal.go new file mode 100644 index 0000000000000000000000000000000000000000..c89b3e5d7431cffcc32fa1ba88e9a7081503a686 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/universal.go differ diff --git a/vendor/github.com/go-redis/redis/v8/version.go b/vendor/github.com/go-redis/redis/v8/version.go new file mode 100644 index 0000000000000000000000000000000000000000..112c9a2da0e35d79c0d4f6ef850f643d875135d4 Binary files /dev/null and b/vendor/github.com/go-redis/redis/v8/version.go differ diff --git a/vendor/modules.txt b/vendor/modules.txt index 23274af250deb610957051d0537da82d5329fe6b..f36681cf42e13d967327c4095c04fbad9c5e8769 100644 Binary files a/vendor/modules.txt and b/vendor/modules.txt differ