diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20ad6ebf4f2a519e2aa0fa8e3a01c80470053df2..7ba775a534d64291955648e24da611f3c5a3cd99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,65 +1,31 @@ -variables: - HELPERS_FILE: docker-build.yml - HELM_HELPERS_FILE: helm.yml - APP_HELM_NAME: cache - DOCKER_FILE: deployment/ci/Dockerfile - stages: - - compile - test - - build - - helm - - deploy -include: - - project: "${HELPERS_PATH}" - file: "${HELPERS_FILE}" - - template: "Workflows/Branch-Pipelines.gitlab-ci.yml" - - project: "$HELM_HELPERS_PATH}" - file: "${HELM_HELPERS_FILE}" +before_script: + - ln -s /builds /go/src/gitlab.eclipse.org + - cd /go/src/gitlab.eclipse.org/${CI_PROJECT_PATH} -lint: - image: golangci/golangci-lint:v1.50.1 +linters: + image: golangci/golangci-lint:latest stage: test - tags: - - amd64-docker script: + - go version - golangci-lint --version - golangci-lint run - before_script: - - ln -s /builds /go/src/gitlab.com - - cd /go/src/gitlab.com/${CI_PROJECT_PATH} unit tests: - image: golang:1.19.4 - extends: .gotest + image: golang:1.21.3 stage: test - tags: - - amd64-docker - before_script: [] + script: + - go version + - go test -race ./... -coverprofile=coverage.out + - go tool cover -func=coverage.out coverage: '/total:\s+\(statements\)\s+(\d+.\d+\%)/' govulncheck: - image: golang:1.19.4 + image: golang:1.21.3 stage: test - tags: - - amd64-docker - before_script: - - ln -s /builds /go/src/gitlab.com - - cd /go/src/gitlab.com/${CI_PROJECT_PATH} script: - go version - go install golang.org/x/vuln/cmd/govulncheck@latest - govulncheck ./... - -amd64: - extends: .docker-build - stage: build - tags: - - amd64-docker - -helm-lint: - extends: .helm-lint - stage: helm - tags: - - amd64-docker diff --git a/cmd/cache/main.go b/cmd/cache/main.go index 98d8c05e68cd6ae517d1fdf5b3240f525beffc18..d7dc8cb9b316635aa9e5ef587858b45b08d34c19 100644 --- a/cmd/cache/main.go +++ b/cmd/cache/main.go @@ -66,7 +66,7 @@ func main() { ) { cacheSvc = cache.New(redis, events, logger) - healthSvc = health.New() + healthSvc = health.New(Version) } // create endpoints diff --git a/deployment/ci/Dockerfile b/deployment/ci/Dockerfile index c668c9e2e46a2f1d73aa3c8e0b78edd6105d4872..45bf93bb5061821db882130f7b9b826806af4ee0 100644 --- a/deployment/ci/Dockerfile +++ b/deployment/ci/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.0-alpine3.17 as builder +FROM golang:1.21.3-alpine3.17 as builder RUN apk add git diff --git a/deployment/compose/Dockerfile b/deployment/compose/Dockerfile index a4454b07779256729ca3b421ce553abcabde3565..e9d3baeaf73b41a653953d21efab82ca482ce244 100644 --- a/deployment/compose/Dockerfile +++ b/deployment/compose/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.0 +FROM golang:1.21.3 RUN go install github.com/ysmood/kit/cmd/guard@v0.25.11 diff --git a/design/design.go b/design/design.go index b0de46f5bcda553a1ec8a92b595d368b8b20c097..470b6a6e27c714cd3524267766e900f15f042233 100644 --- a/design/design.go +++ b/design/design.go @@ -20,7 +20,7 @@ var _ = Service("health", func() { Method("Liveness", func() { Payload(Empty) - Result(Empty) + Result(HealthResponse) HTTP(func() { GET("/liveness") Response(StatusOK) @@ -29,7 +29,7 @@ var _ = Service("health", func() { Method("Readiness", func() { Payload(Empty) - Result(Empty) + Result(HealthResponse) HTTP(func() { GET("/readiness") Response(StatusOK) diff --git a/design/types.go b/design/types.go index ae43f342ab8a1aa8037758c977406e4959df9ab6..eee0825d85ed07a661c979e8a5d8ea51edcc2740 100644 --- a/design/types.go +++ b/design/types.go @@ -18,3 +18,10 @@ var CacheSetRequest = Type("CacheSetRequest", func() { Field(5, "ttl", Int) Required("data", "key") }) + +var HealthResponse = Type("HealthResponse", func() { + Field(1, "service", String, "Service name.") + Field(2, "status", String, "Status message.") + Field(3, "version", String, "Service runtime version.") + Required("service", "status", "version") +}) diff --git a/gen/health/client.go b/gen/health/client.go index e981f5517b8f374c6c8da41bbe84fab289299a50..5be9526ea7efd4ec67f77877e460417e16ee17fc 100644 --- a/gen/health/client.go +++ b/gen/health/client.go @@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client { } // Liveness calls the "Liveness" endpoint of the "health" service. -func (c *Client) Liveness(ctx context.Context) (err error) { - _, err = c.LivenessEndpoint(ctx, nil) - return +func (c *Client) Liveness(ctx context.Context) (res *HealthResponse, err error) { + var ires any + ires, err = c.LivenessEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(*HealthResponse), nil } // Readiness calls the "Readiness" endpoint of the "health" service. -func (c *Client) Readiness(ctx context.Context) (err error) { - _, err = c.ReadinessEndpoint(ctx, nil) - return +func (c *Client) Readiness(ctx context.Context) (res *HealthResponse, err error) { + var ires any + ires, err = c.ReadinessEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(*HealthResponse), nil } diff --git a/gen/health/endpoints.go b/gen/health/endpoints.go index 69ab505ce8234dede2a1cdb360ad330759612f60..4084e47f82a8f980e1205dd1fc08115890d239ed 100644 --- a/gen/health/endpoints.go +++ b/gen/health/endpoints.go @@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { // "Liveness" of service "health". func NewLivenessEndpoint(s Service) goa.Endpoint { return func(ctx context.Context, req any) (any, error) { - return nil, s.Liveness(ctx) + return s.Liveness(ctx) } } @@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint { // "Readiness" of service "health". func NewReadinessEndpoint(s Service) goa.Endpoint { return func(ctx context.Context, req any) (any, error) { - return nil, s.Readiness(ctx) + return s.Readiness(ctx) } } diff --git a/gen/health/service.go b/gen/health/service.go index 31e6a594f3e28291510d6c2884c53476e3c6c4e2..960544a03eff55942552e068ebe0fd1b0513ffda 100644 --- a/gen/health/service.go +++ b/gen/health/service.go @@ -14,9 +14,9 @@ import ( // Health service provides health check endpoints. type Service interface { // Liveness implements Liveness. - Liveness(context.Context) (err error) + Liveness(context.Context) (res *HealthResponse, err error) // Readiness implements Readiness. - Readiness(context.Context) (err error) + Readiness(context.Context) (res *HealthResponse, err error) } // ServiceName is the name of the service as defined in the design. This is the @@ -28,3 +28,13 @@ const ServiceName = "health" // are the same values that are set in the endpoint request contexts under the // MethodKey key. var MethodNames = [2]string{"Liveness", "Readiness"} + +// HealthResponse is the result type of the health service Liveness method. +type HealthResponse struct { + // Service name. + Service string + // Status message. + Status string + // Service runtime version. + Version string +} diff --git a/gen/http/cache/client/cli.go b/gen/http/cache/client/cli.go index 73e49f764da8799c4cd47a13d8896184d260fe4a..4f75bd46a479ad1a576bbd0fac478d8a3298f7ba 100644 --- a/gen/http/cache/client/cli.go +++ b/gen/http/cache/client/cli.go @@ -48,7 +48,7 @@ func BuildSetPayload(cacheSetBody string, cacheSetKey string, cacheSetNamespace { err = json.Unmarshal([]byte(cacheSetBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Corporis omnis itaque earum quasi.\"") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Dolorem et quam et illum.\"") } } var key string @@ -99,7 +99,7 @@ func BuildSetExternalPayload(cacheSetExternalBody string, cacheSetExternalKey st { err = json.Unmarshal([]byte(cacheSetExternalBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Enim vel.\"") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Quis rerum velit sunt rerum dignissimos at.\"") } } var key string diff --git a/gen/http/cli/cache/cli.go b/gen/http/cli/cache/cli.go index 5b6086b64aea0a9d397860931e6f9c2982583d2a..44fb882cbf558eca3f57bf7e8d0ffe88a836ddaf 100644 --- a/gen/http/cli/cache/cli.go +++ b/gen/http/cli/cache/cli.go @@ -23,15 +23,15 @@ import ( // // command (subcommand1|subcommand2|...) func UsageCommands() string { - return `health (liveness|readiness) -cache (get|set|set-external) + return `cache (get|set|set-external) +health (liveness|readiness) ` } // 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 "Sed consequatur rerum occaecati." --namespace "Veritatis exercitationem repudiandae eos." --scope "Sint dolorum occaecati."` + "\n" + + return os.Args[0] + ` cache get --key "Voluptatum modi tenetur tempore quia est ratione." --namespace "Corrupti sunt dolores." --scope "Repellat omnis id ex."` + "\n" + + os.Args[0] + ` health liveness` + "\n" + "" } @@ -45,12 +45,6 @@ func ParseEndpoint( restore bool, ) (goa.Endpoint, any, error) { var ( - healthFlags = flag.NewFlagSet("health", flag.ContinueOnError) - - healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError) - - healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError) - cacheFlags = flag.NewFlagSet("cache", flag.ContinueOnError) cacheGetFlags = flag.NewFlagSet("get", flag.ExitOnError) @@ -71,16 +65,22 @@ func ParseEndpoint( cacheSetExternalNamespaceFlag = cacheSetExternalFlags.String("namespace", "", "") cacheSetExternalScopeFlag = cacheSetExternalFlags.String("scope", "", "") cacheSetExternalTTLFlag = cacheSetExternalFlags.String("ttl", "", "") - ) - healthFlags.Usage = healthUsage - healthLivenessFlags.Usage = healthLivenessUsage - healthReadinessFlags.Usage = healthReadinessUsage + healthFlags = flag.NewFlagSet("health", flag.ContinueOnError) + + healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError) + + healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError) + ) cacheFlags.Usage = cacheUsage cacheGetFlags.Usage = cacheGetUsage cacheSetFlags.Usage = cacheSetUsage cacheSetExternalFlags.Usage = cacheSetExternalUsage + healthFlags.Usage = healthUsage + healthLivenessFlags.Usage = healthLivenessUsage + healthReadinessFlags.Usage = healthReadinessUsage + if err := flag.CommandLine.Parse(os.Args[1:]); err != nil { return nil, nil, err } @@ -96,10 +96,10 @@ func ParseEndpoint( { svcn = flag.Arg(0) switch svcn { - case "health": - svcf = healthFlags case "cache": svcf = cacheFlags + case "health": + svcf = healthFlags default: return nil, nil, fmt.Errorf("unknown service %q", svcn) } @@ -115,16 +115,6 @@ func ParseEndpoint( { epn = svcf.Arg(0) switch svcn { - case "health": - switch epn { - case "liveness": - epf = healthLivenessFlags - - case "readiness": - epf = healthReadinessFlags - - } - case "cache": switch epn { case "get": @@ -138,6 +128,16 @@ func ParseEndpoint( } + case "health": + switch epn { + case "liveness": + epf = healthLivenessFlags + + case "readiness": + epf = healthReadinessFlags + + } + } } if epf == nil { @@ -158,16 +158,6 @@ func ParseEndpoint( ) { switch svcn { - case "health": - c := healthc.NewClient(scheme, host, doer, enc, dec, restore) - switch epn { - case "liveness": - endpoint = c.Liveness() - data = nil - case "readiness": - endpoint = c.Readiness() - data = nil - } case "cache": c := cachec.NewClient(scheme, host, doer, enc, dec, restore) switch epn { @@ -181,6 +171,16 @@ func ParseEndpoint( endpoint = c.SetExternal() data, err = cachec.BuildSetExternalPayload(*cacheSetExternalBodyFlag, *cacheSetExternalKeyFlag, *cacheSetExternalNamespaceFlag, *cacheSetExternalScopeFlag, *cacheSetExternalTTLFlag) } + case "health": + c := healthc.NewClient(scheme, host, doer, enc, dec, restore) + switch epn { + case "liveness": + endpoint = c.Liveness() + data = nil + case "readiness": + endpoint = c.Readiness() + data = nil + } } } if err != nil { @@ -190,40 +190,6 @@ func ParseEndpoint( return endpoint, data, nil } -// healthUsage displays the usage of the health command and its subcommands. -func healthUsage() { - fmt.Fprintf(os.Stderr, `Health service provides health check endpoints. -Usage: - %[1]s [globalflags] health COMMAND [flags] - -COMMAND: - liveness: Liveness implements Liveness. - readiness: Readiness implements Readiness. - -Additional help: - %[1]s health COMMAND --help -`, os.Args[0]) -} -func healthLivenessUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness - -Liveness implements Liveness. - -Example: - %[1]s health liveness -`, os.Args[0]) -} - -func healthReadinessUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness - -Readiness implements Readiness. - -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. @@ -248,7 +214,7 @@ Get JSON value from the cache. -scope STRING: Example: - %[1]s cache get --key "Sed consequatur rerum occaecati." --namespace "Veritatis exercitationem repudiandae eos." --scope "Sint dolorum occaecati." + %[1]s cache get --key "Voluptatum modi tenetur tempore quia est ratione." --namespace "Corrupti sunt dolores." --scope "Repellat omnis id ex." `, os.Args[0]) } @@ -263,7 +229,7 @@ Set a JSON value in the cache. -ttl INT: Example: - %[1]s cache set --body "Corporis omnis itaque earum quasi." --key "Et eligendi nihil optio natus assumenda." --namespace "Quasi perspiciatis." --scope "Accusantium animi non alias." --ttl 3495630911155968941 + %[1]s cache set --body "Dolorem et quam et illum." --key "Esse inventore ullam placeat aut." --namespace "Omnis itaque." --scope "Quasi ut." --ttl 3100652887298323449 `, os.Args[0]) } @@ -278,6 +244,40 @@ Set an external JSON value in the cache and provide an event for the input. -ttl INT: Example: - %[1]s cache set-external --body "Enim vel." --key "Ut in." --namespace "Ab dolores distinctio quis." --scope "Optio aliquam error nam." --ttl 2227603043401673122 + %[1]s cache set-external --body "Quis rerum velit sunt rerum dignissimos at." --key "Optio aliquam error nam." --namespace "Recusandae illo." --scope "Placeat veniam veritatis doloribus." --ttl 5137048679846705449 +`, os.Args[0]) +} + +// healthUsage displays the usage of the health command and its subcommands. +func healthUsage() { + fmt.Fprintf(os.Stderr, `Health service provides health check endpoints. +Usage: + %[1]s [globalflags] health COMMAND [flags] + +COMMAND: + liveness: Liveness implements Liveness. + readiness: Readiness implements Readiness. + +Additional help: + %[1]s health COMMAND --help +`, os.Args[0]) +} +func healthLivenessUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness + +Liveness implements Liveness. + +Example: + %[1]s health liveness +`, os.Args[0]) +} + +func healthReadinessUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness + +Readiness implements Readiness. + +Example: + %[1]s health readiness `, os.Args[0]) } diff --git a/gen/http/health/client/encode_decode.go b/gen/http/health/client/encode_decode.go index cb20154956dedf0e69af4da9145e656b927f4666..952812eaa10aabb2cc9abb8ec90dff5f03895e1d 100644 --- a/gen/http/health/client/encode_decode.go +++ b/gen/http/health/client/encode_decode.go @@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor } switch resp.StatusCode { case http.StatusOK: - return nil, nil + var ( + body LivenessResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "Liveness", err) + } + err = ValidateLivenessResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("health", "Liveness", err) + } + res := NewLivenessHealthResponseOK(&body) + return res, nil default: body, _ := io.ReadAll(resp.Body) return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body)) @@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto } switch resp.StatusCode { case http.StatusOK: - return nil, nil + var ( + body ReadinessResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "Readiness", err) + } + err = ValidateReadinessResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("health", "Readiness", err) + } + res := NewReadinessHealthResponseOK(&body) + return res, nil default: body, _ := io.ReadAll(resp.Body) return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body)) diff --git a/gen/http/health/client/types.go b/gen/http/health/client/types.go index 409dc360abe9ce472e0e90dd4c12416188c8dab0..b6b3b4ecffc4ffd1b3897c19257a6cfca01494aa 100644 --- a/gen/http/health/client/types.go +++ b/gen/http/health/client/types.go @@ -6,3 +6,84 @@ // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/cache/design package client + +import ( + health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health" + goa "goa.design/goa/v3/pkg" +) + +// LivenessResponseBody is the type of the "health" service "Liveness" endpoint +// HTTP response body. +type LivenessResponseBody struct { + // Service name. + Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"` + // Status message. + Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"` + // Service runtime version. + Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"` +} + +// ReadinessResponseBody is the type of the "health" service "Readiness" +// endpoint HTTP response body. +type ReadinessResponseBody struct { + // Service name. + Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"` + // Status message. + Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"` + // Service runtime version. + Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"` +} + +// NewLivenessHealthResponseOK builds a "health" service "Liveness" endpoint +// result from a HTTP "OK" response. +func NewLivenessHealthResponseOK(body *LivenessResponseBody) *health.HealthResponse { + v := &health.HealthResponse{ + Service: *body.Service, + Status: *body.Status, + Version: *body.Version, + } + + return v +} + +// NewReadinessHealthResponseOK builds a "health" service "Readiness" endpoint +// result from a HTTP "OK" response. +func NewReadinessHealthResponseOK(body *ReadinessResponseBody) *health.HealthResponse { + v := &health.HealthResponse{ + Service: *body.Service, + Status: *body.Status, + Version: *body.Version, + } + + return v +} + +// ValidateLivenessResponseBody runs the validations defined on +// LivenessResponseBody +func ValidateLivenessResponseBody(body *LivenessResponseBody) (err error) { + if body.Service == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("service", "body")) + } + if body.Status == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("status", "body")) + } + if body.Version == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("version", "body")) + } + return +} + +// ValidateReadinessResponseBody runs the validations defined on +// ReadinessResponseBody +func ValidateReadinessResponseBody(body *ReadinessResponseBody) (err error) { + if body.Service == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("service", "body")) + } + if body.Status == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("status", "body")) + } + if body.Version == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("version", "body")) + } + return +} diff --git a/gen/http/health/server/encode_decode.go b/gen/http/health/server/encode_decode.go index 1bb4927c1102ec400119a44efb7a2fe75a3bc2fc..1b6dc0e4d005d76b306948ed4b84185e813753e6 100644 --- a/gen/http/health/server/encode_decode.go +++ b/gen/http/health/server/encode_decode.go @@ -11,6 +11,7 @@ import ( "context" "net/http" + health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health" goahttp "goa.design/goa/v3/http" ) @@ -18,8 +19,11 @@ import ( // health Liveness endpoint. func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error { + res, _ := v.(*health.HealthResponse) + enc := encoder(ctx, w) + body := NewLivenessResponseBody(res) w.WriteHeader(http.StatusOK) - return nil + return enc.Encode(body) } } @@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g // health Readiness endpoint. func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error { + res, _ := v.(*health.HealthResponse) + enc := encoder(ctx, w) + body := NewReadinessResponseBody(res) w.WriteHeader(http.StatusOK) - return nil + return enc.Encode(body) } } diff --git a/gen/http/health/server/types.go b/gen/http/health/server/types.go index 5ad49ba49335195a74667666406f9e994c92ab89..48e5d9438769f9c509a51f012e0e85a244f325f3 100644 --- a/gen/http/health/server/types.go +++ b/gen/http/health/server/types.go @@ -6,3 +6,51 @@ // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/cache/design package server + +import ( + health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health" +) + +// LivenessResponseBody is the type of the "health" service "Liveness" endpoint +// HTTP response body. +type LivenessResponseBody struct { + // Service name. + Service string `form:"service" json:"service" xml:"service"` + // Status message. + Status string `form:"status" json:"status" xml:"status"` + // Service runtime version. + Version string `form:"version" json:"version" xml:"version"` +} + +// ReadinessResponseBody is the type of the "health" service "Readiness" +// endpoint HTTP response body. +type ReadinessResponseBody struct { + // Service name. + Service string `form:"service" json:"service" xml:"service"` + // Status message. + Status string `form:"status" json:"status" xml:"status"` + // Service runtime version. + Version string `form:"version" json:"version" xml:"version"` +} + +// NewLivenessResponseBody builds the HTTP response body from the result of the +// "Liveness" endpoint of the "health" service. +func NewLivenessResponseBody(res *health.HealthResponse) *LivenessResponseBody { + body := &LivenessResponseBody{ + Service: res.Service, + Status: res.Status, + Version: res.Version, + } + return body +} + +// NewReadinessResponseBody builds the HTTP response body from the result of +// the "Readiness" endpoint of the "health" service. +func NewReadinessResponseBody(res *health.HealthResponse) *ReadinessResponseBody { + body := &ReadinessResponseBody{ + Service: res.Service, + Status: res.Status, + Version: res.Version, + } + return body +} diff --git a/gen/http/openapi.json b/gen/http/openapi.json index db6dba5cfe04622d911f3e0751f9cc4b850e9974..febee9e13843c7696b10226d473cbc0aeeb535e8 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: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 JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"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.","schema":{"$ref":"#/definitions/HealthLivenessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthReadinessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","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":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}}},"definitions":{"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Laborum reprehenderit rerum est et ut dolores."},"status":{"type":"string","description":"Status message.","example":"Consequatur porro qui est dolor a."},"version":{"type":"string","description":"Service runtime version.","example":"Ad dolor."}},"example":{"service":"Fugiat voluptatem vel et.","status":"Sint tempore est nam iusto.","version":"Ipsam quidem aut velit vitae est."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Repellat qui totam et recusandae."},"status":{"type":"string","description":"Status message.","example":"Dolores at qui aliquam ullam."},"version":{"type":"string","description":"Service runtime version.","example":"Omnis ex fugit corporis."}},"example":{"service":"Minima sed et.","status":"Veniam optio qui.","version":"Suscipit velit aliquid et."},"required":["service","status","version"]}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index 318deff9c50515a43c6516246403fc4ae8b59da5..3648e0c82368173c51c7c1ff87e89388b3fb8042 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -22,6 +22,12 @@ paths: responses: "200": description: OK response. + schema: + $ref: '#/definitions/HealthLivenessResponseBody' + required: + - service + - status + - version schemes: - http /readiness: @@ -33,6 +39,12 @@ paths: responses: "200": description: OK response. + schema: + $ref: '#/definitions/HealthReadinessResponseBody' + required: + - service + - status + - version schemes: - http /v1/cache: @@ -145,3 +157,52 @@ paths: description: OK response. schemes: - http +definitions: + HealthLivenessResponseBody: + title: HealthLivenessResponseBody + type: object + properties: + service: + type: string + description: Service name. + example: Laborum reprehenderit rerum est et ut dolores. + status: + type: string + description: Status message. + example: Consequatur porro qui est dolor a. + version: + type: string + description: Service runtime version. + example: Ad dolor. + example: + service: Fugiat voluptatem vel et. + status: Sint tempore est nam iusto. + version: Ipsam quidem aut velit vitae est. + required: + - service + - status + - version + HealthReadinessResponseBody: + title: HealthReadinessResponseBody + type: object + properties: + service: + type: string + description: Service name. + example: Repellat qui totam et recusandae. + status: + type: string + description: Status message. + example: Dolores at qui aliquam ullam. + version: + type: string + description: Service runtime version. + example: Omnis ex fugit corporis. + example: + service: Minima sed et. + status: Veniam optio qui. + version: Suscipit velit aliquid et. + required: + - service + - status + - version diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 5ca1b4375609d2baac7a6b758f36b94141c1e3a2..605856bfa27850eb6f1bf81f1b1101d5742ed5ec 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: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 JSON value from the cache.","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Delectus quaerat molestiae placeat nemo.","format":"binary"},"example":"Quia dolores rem."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Quis rerum velit sunt rerum dignissimos at.","format":"binary"},"example":"Est illum."}}},"responses":{"201":{"description":"Created response."}}}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Molestiae minima.","format":"binary"},"example":"Repellendus quo."}}},"responses":{"200":{"description":"OK response."}}}}},"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 +{"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.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Molestiae minima.","status":"Quia dolores rem.","version":"Est illum."}}}}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Repellendus quo.","status":"Cumque aut.","version":"Sit sint ipsa fugiat et id rem."}}}}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Rerum et qui alias qui.","format":"binary"},"example":"Accusamus ratione voluptatibus."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Beatae commodi.","format":"binary"},"example":"Quae minus maiores nulla deleniti ipsa."}}},"responses":{"201":{"description":"Created response."}}}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","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,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Fuga voluptas explicabo et libero.","format":"binary"},"example":"Quidem nihil quis tempore."}}},"responses":{"200":{"description":"OK response."}}}}},"components":{"schemas":{"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Illum nam ratione nisi."},"status":{"type":"string","description":"Status message.","example":"Labore vel."},"version":{"type":"string","description":"Service runtime version.","example":"Aut illum."}},"example":{"service":"Itaque vel.","status":"Itaque enim aut consequatur beatae ut.","version":"Et atque impedit nostrum perspiciatis ipsum."},"required":["service","status","version"]}}},"tags":[{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."},{"name":"health","description":"Health service provides health check endpoints."}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 5b5d95762fe4893de50198869bb9753df65c4a8f..61ccd2d10543d218a16fb87c715c17cafe1d589b 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -16,6 +16,14 @@ paths: responses: "200": description: OK response. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthResponse' + example: + service: Molestiae minima. + status: Quia dolores rem. + version: Est illum. /readiness: get: tags: @@ -25,6 +33,14 @@ paths: responses: "200": description: OK response. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthResponse' + example: + service: Repellendus quo. + status: Cumque aut. + version: Sit sint ipsa fugiat et id rem. /v1/cache: get: tags: @@ -68,9 +84,9 @@ paths: application/json: schema: type: string - example: Delectus quaerat molestiae placeat nemo. + example: Rerum et qui alias qui. format: binary - example: Quia dolores rem. + example: Accusamus ratione voluptatibus. post: tags: - cache @@ -122,9 +138,9 @@ paths: application/json: schema: type: string - example: Quis rerum velit sunt rerum dignissimos at. + example: Beatae commodi. format: binary - example: Est illum. + example: Quae minus maiores nulla deleniti ipsa. responses: "201": description: Created response. @@ -180,15 +196,39 @@ paths: application/json: schema: type: string - example: Molestiae minima. + example: Fuga voluptas explicabo et libero. format: binary - example: Repellendus quo. + example: Quidem nihil quis tempore. responses: "200": description: OK response. -components: {} +components: + schemas: + HealthResponse: + type: object + properties: + service: + type: string + description: Service name. + example: Illum nam ratione nisi. + status: + type: string + description: Status message. + example: Labore vel. + version: + type: string + description: Service runtime version. + example: Aut illum. + example: + service: Itaque vel. + status: Itaque enim aut consequatur beatae ut. + version: Et atque impedit nostrum perspiciatis ipsum. + required: + - service + - status + - version tags: - - name: health - description: Health service provides health check endpoints. - name: cache description: Cache service allows storing and retrieving data from distributed cache. + - name: health + description: Health service provides health check endpoints. diff --git a/go.mod b/go.mod index 736747438d02e70c24be269f729c9637cc3a6051..b829da08f6653aa13df91e531c082f2f98cb36cf 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gitlab.eclipse.org/eclipse/xfsc/tsa/cache -go 1.20 +go 1.21 require ( github.com/cloudevents/sdk-go/protocol/nats/v2 v2.14.0 diff --git a/go.sum b/go.sum index ce9b02b0e80b1313772c1d3b4a3f1f45867c7940..0d7a4c8df804f1782418b637e150a6cf2954f9ae 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,11 @@ github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= +github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= +github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cloudevents/sdk-go/protocol/nats/v2 v2.14.0 h1:cPOXwhwRb+RtHrPSs6Qmobgt4q/0e4wNBdfUjOeV9Qw= @@ -30,8 +33,10 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4 h1:OL2d27ueTKnlQJoqLW2fc9pWYulFnJYLWzomGV7HqZo= +github.com/google/gxui v0.0.0-20151028112939-f85e0a97b3a4/go.mod h1:Pw1H1OjSNHiqeuxAduB1BKYXIwFtsyrY47nEqSgEiCM= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= @@ -48,9 +53,11 @@ github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGC github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= @@ -67,6 +74,7 @@ github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmt github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d h1:Zj+PHjnhRYWBK6RqCDBcAhLXoi3TzC27Zad/Vn+gnVQ= github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d/go.mod h1:WZy8Q5coAB1zhY9AOBJP0O6J4BuDfbupUDavKY+I3+s= github.com/manveru/gobdd v0.0.0-20131210092515-f1a17fdd710b h1:3E44bLeN8uKYdfQqVQycPnaVviZdBLbizFhU49mtbe4= +github.com/manveru/gobdd v0.0.0-20131210092515-f1a17fdd710b/go.mod h1:Bj8LjjP0ReT1eKt5QlKjwgi5AFm5mI6O1A2G4ChI0Ag= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= @@ -79,6 +87,7 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/nats-io/jwt/v2 v2.4.1 h1:Y35W1dgbbz2SQUYDPCaclXcuqleVmpbRa7646Jf2EX4= github.com/nats-io/jwt/v2 v2.4.1/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI= github.com/nats-io/nats-server/v2 v2.7.4 h1:c+BZJ3rGzUKCBIM4IXO8uNT2u1vajGbD1kPA6wqCEaM= +github.com/nats-io/nats-server/v2 v2.7.4/go.mod h1:1vZ2Nijh8tcyNe8BDVyTviCd9NYzRbubQYiEHsvOQWc= github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d h1:zJf4l8Kp67RIZhoVeniSLZs69SHNgjLHz0aNsqPPlx8= github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= @@ -107,6 +116,7 @@ github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NF github.com/smartystreets/assertions v1.13.0 h1:Dx1kYM01xsSqKPno3aqLnrwac2LetPvN23diwyr69Qs= github.com/smartystreets/assertions v1.13.0/go.mod h1:wDmR7qL282YbGsPy6H/yAsesrxfxaaSlJazyFLYVFx8= github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= +github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -118,12 +128,14 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea h1:CyhwejzVGvZ3Q2PSbQ4NRRYn+ZWv5eS1vlaEusT+bAI= github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea/go.mod h1:eNr558nEUjP8acGw8FFjTeWvSgU1stO7FAO6eknhHe4= gitlab.eclipse.org/eclipse/xfsc/tsa/golib v1.3.2-0.20230810143053-d53786b08923 h1:ayI4Qs9bPMuAccDM9pBGMnO1EXYyIPgK4EvlD4Kffs4= gitlab.eclipse.org/eclipse/xfsc/tsa/golib v1.3.2-0.20230810143053-d53786b08923/go.mod h1:csApc+9NYX7AoquLOLu644c/uxuPAVhv+kJpOAe3npg= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= @@ -173,6 +185,7 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -188,6 +201,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/service/health/service.go b/internal/service/health/service.go index ffa6d9af3d67b8681ce5464bc555ca38aa6b801e..25177bc15aabf807448f07d17a1497761d7c591d 100644 --- a/internal/service/health/service.go +++ b/internal/service/health/service.go @@ -1,17 +1,31 @@ package health -import "context" +import ( + "context" -type Service struct{} + "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health" +) -func New() *Service { - return &Service{} +type Service struct { + version string } -func (s *Service) Liveness(ctx context.Context) error { - return nil +func New(version string) *Service { + return &Service{version: version} } -func (s *Service) Readiness(ctx context.Context) error { - return nil +func (s *Service) Liveness(_ context.Context) (*health.HealthResponse, error) { + return &health.HealthResponse{ + Service: "cache", + Status: "up", + Version: s.version, + }, nil +} + +func (s *Service) Readiness(_ context.Context) (*health.HealthResponse, error) { + return &health.HealthResponse{ + Service: "cache", + Status: "up", + Version: s.version, + }, nil }