diff --git a/charts/cloudevents-server/Chart.yaml b/charts/cloudevents-server/Chart.yaml index f46e6bd..af15539 100644 --- a/charts/cloudevents-server/Chart.yaml +++ b/charts/cloudevents-server/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/dl/templates/deployment.yaml b/charts/dl/templates/deployment.yaml index b0c9b28..95a9e0d 100644 --- a/charts/dl/templates/deployment.yaml +++ b/charts/dl/templates/deployment.yaml @@ -43,11 +43,11 @@ spec: protocol: TCP livenessProbe: httpGet: - path: / + path: /livez port: http readinessProbe: httpGet: - path: / + path: /healthz port: http resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/dl/templates/tests/test-connection.yaml b/charts/dl/templates/tests/test-connection.yaml index d015ccc..e1a9ed4 100644 --- a/charts/dl/templates/tests/test-connection.yaml +++ b/charts/dl/templates/tests/test-connection.yaml @@ -11,5 +11,5 @@ spec: - name: wget image: busybox command: ['wget'] - args: ['{{ include "dl.fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include "dl.fullname" . }}:{{ .Values.service.port }}/healthz'] restartPolicy: Never diff --git a/dl/cmd/server/http.go b/dl/cmd/server/http.go index baeabc7..f22874e 100644 --- a/dl/cmd/server/http.go +++ b/dl/cmd/server/http.go @@ -9,6 +9,8 @@ import ( "sync" "time" + health "github.com/PingCAP-QE/ee-apps/dl/gen/health" + healthsvr "github.com/PingCAP-QE/ee-apps/dl/gen/http/health/server" ks3svr "github.com/PingCAP-QE/ee-apps/dl/gen/http/ks3/server" ocisvr "github.com/PingCAP-QE/ee-apps/dl/gen/http/oci/server" ks3 "github.com/PingCAP-QE/ee-apps/dl/gen/ks3" @@ -20,7 +22,7 @@ import ( // handleHTTPServer starts configures and starts a HTTP server on the given // URL. It shuts down the server if any error is received in the error channel. -func handleHTTPServer(ctx context.Context, u *url.URL, ociEndpoints *oci.Endpoints, ks3Endpoints *ks3.Endpoints, wg *sync.WaitGroup, errc chan error, logger *log.Logger, debug bool) { +func handleHTTPServer(ctx context.Context, u *url.URL, healthEndpoints *health.Endpoints, ociEndpoints *oci.Endpoints, ks3Endpoints *ks3.Endpoints, wg *sync.WaitGroup, errc chan error, logger *log.Logger, debug bool) { // Setup goa log adapter. var ( @@ -51,15 +53,18 @@ func handleHTTPServer(ctx context.Context, u *url.URL, ociEndpoints *oci.Endpoin // the service input and output data structures to HTTP requests and // responses. var ( - ociServer *ocisvr.Server - ks3Server *ks3svr.Server + healthServer *healthsvr.Server + ociServer *ocisvr.Server + ks3Server *ks3svr.Server ) { eh := errorHandler(logger) + healthServer = healthsvr.New(healthEndpoints, mux, dec, enc, eh, nil) ociServer = ocisvr.New(ociEndpoints, mux, dec, enc, eh, nil) ks3Server = ks3svr.New(ks3Endpoints, mux, dec, enc, eh, nil) if debug { servers := goahttp.Servers{ + healthServer, ociServer, ks3Server, } @@ -67,6 +72,7 @@ func handleHTTPServer(ctx context.Context, u *url.URL, ociEndpoints *oci.Endpoin } } // Configure the mux. + healthsvr.Mount(mux, healthServer) ocisvr.Mount(mux, ociServer) ks3svr.Mount(mux, ks3Server) @@ -81,6 +87,9 @@ func handleHTTPServer(ctx context.Context, u *url.URL, ociEndpoints *oci.Endpoin // Start HTTP server using default configuration, change the code to // configure the server as required by your service. srv := &http.Server{Addr: u.Host, Handler: handler, ReadHeaderTimeout: time.Second * 60} + for _, m := range healthServer.Mounts { + logger.Printf("HTTP %q mounted on %s %s", m.Method, m.Verb, m.Pattern) + } for _, m := range ociServer.Mounts { logger.Printf("HTTP %q mounted on %s %s", m.Method, m.Verb, m.Pattern) } diff --git a/dl/cmd/server/main.go b/dl/cmd/server/main.go index 1028f4a..ef7580c 100644 --- a/dl/cmd/server/main.go +++ b/dl/cmd/server/main.go @@ -13,6 +13,7 @@ import ( "syscall" dl "github.com/PingCAP-QE/ee-apps/dl" + health "github.com/PingCAP-QE/ee-apps/dl/gen/health" ks3 "github.com/PingCAP-QE/ee-apps/dl/gen/ks3" oci "github.com/PingCAP-QE/ee-apps/dl/gen/oci" ) @@ -40,10 +41,12 @@ func main() { // Initialize the services. var ( - ociSvc oci.Service - ks3Svc ks3.Service + healthSvc health.Service + ociSvc oci.Service + ks3Svc ks3.Service ) { + healthSvc = dl.NewHealth(logger) ociSvc = dl.NewOci(logger) ks3Svc = dl.NewKs3(logger, *ks3CfgPathF) } @@ -51,10 +54,12 @@ func main() { // Wrap the services in endpoints that can be invoked from other services // potentially running in different processes. var ( - ociEndpoints *oci.Endpoints - ks3Endpoints *ks3.Endpoints + healthEndpoints *health.Endpoints + ociEndpoints *oci.Endpoints + ks3Endpoints *ks3.Endpoints ) { + healthEndpoints = health.NewEndpoints(healthSvc) ociEndpoints = oci.NewEndpoints(ociSvc) ks3Endpoints = ks3.NewEndpoints(ks3Svc) } @@ -98,7 +103,7 @@ func main() { } else if u.Port() == "" { u.Host = net.JoinHostPort(u.Host, "80") } - handleHTTPServer(ctx, u, ociEndpoints, ks3Endpoints, &wg, errc, logger, *dbgF) + handleHTTPServer(ctx, u, healthEndpoints, ociEndpoints, ks3Endpoints, &wg, errc, logger, *dbgF) } default: diff --git a/dl/design/design.go b/dl/design/design.go index adcd6d1..6734684 100644 --- a/dl/design/design.go +++ b/dl/design/design.go @@ -14,6 +14,24 @@ var _ = API("dl", func() { }) }) +var _ = Service("health", func() { + Description("Health service") + + Method("healthz", func() { + Result(Boolean) + HTTP(func() { + GET("/healthz") + }) + }) + + Method("livez", func() { + Result(Boolean) + HTTP(func() { + GET("/livez") + }) + }) +}) + var _ = Service("oci", func() { Description("OCI artifacts download service") diff --git a/dl/gen/health/client.go b/dl/gen/health/client.go new file mode 100644 index 0000000..f96d23f --- /dev/null +++ b/dl/gen/health/client.go @@ -0,0 +1,48 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health client +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package health + +import ( + "context" + + goa "goa.design/goa/v3/pkg" +) + +// Client is the "health" service client. +type Client struct { + HealthzEndpoint goa.Endpoint + LivezEndpoint goa.Endpoint +} + +// NewClient initializes a "health" service client given the endpoints. +func NewClient(healthz, livez goa.Endpoint) *Client { + return &Client{ + HealthzEndpoint: healthz, + LivezEndpoint: livez, + } +} + +// Healthz calls the "healthz" endpoint of the "health" service. +func (c *Client) Healthz(ctx context.Context) (res bool, err error) { + var ires any + ires, err = c.HealthzEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(bool), nil +} + +// Livez calls the "livez" endpoint of the "health" service. +func (c *Client) Livez(ctx context.Context) (res bool, err error) { + var ires any + ires, err = c.LivezEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(bool), nil +} diff --git a/dl/gen/health/endpoints.go b/dl/gen/health/endpoints.go new file mode 100644 index 0000000..efdd456 --- /dev/null +++ b/dl/gen/health/endpoints.go @@ -0,0 +1,50 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health endpoints +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package health + +import ( + "context" + + goa "goa.design/goa/v3/pkg" +) + +// Endpoints wraps the "health" service endpoints. +type Endpoints struct { + Healthz goa.Endpoint + Livez goa.Endpoint +} + +// NewEndpoints wraps the methods of the "health" service with endpoints. +func NewEndpoints(s Service) *Endpoints { + return &Endpoints{ + Healthz: NewHealthzEndpoint(s), + Livez: NewLivezEndpoint(s), + } +} + +// Use applies the given middleware to all the "health" service endpoints. +func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { + e.Healthz = m(e.Healthz) + e.Livez = m(e.Livez) +} + +// NewHealthzEndpoint returns an endpoint function that calls the method +// "healthz" of service "health". +func NewHealthzEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req any) (any, error) { + return s.Healthz(ctx) + } +} + +// NewLivezEndpoint returns an endpoint function that calls the method "livez" +// of service "health". +func NewLivezEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req any) (any, error) { + return s.Livez(ctx) + } +} diff --git a/dl/gen/health/service.go b/dl/gen/health/service.go new file mode 100644 index 0000000..65401fb --- /dev/null +++ b/dl/gen/health/service.go @@ -0,0 +1,30 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health service +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package health + +import ( + "context" +) + +// Health service +type Service interface { + // Healthz implements healthz. + Healthz(context.Context) (res bool, err error) + // Livez implements livez. + Livez(context.Context) (res bool, 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 = "health" + +// 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 = [2]string{"healthz", "livez"} diff --git a/dl/gen/http/cli/server/cli.go b/dl/gen/http/cli/server/cli.go index da77169..7348378 100644 --- a/dl/gen/http/cli/server/cli.go +++ b/dl/gen/http/cli/server/cli.go @@ -13,6 +13,7 @@ import ( "net/http" "os" + healthc "github.com/PingCAP-QE/ee-apps/dl/gen/http/health/client" ks3c "github.com/PingCAP-QE/ee-apps/dl/gen/http/ks3/client" ocic "github.com/PingCAP-QE/ee-apps/dl/gen/http/oci/client" goahttp "goa.design/goa/v3/http" @@ -23,15 +24,17 @@ import ( // // command (subcommand1|subcommand2|...) func UsageCommands() string { - return `oci (list-files|download-file) + return `health (healthz|livez) +oci (list-files|download-file) ks3 download-object ` } // UsageExamples produces an example of a valid invocation of the CLI tool. func UsageExamples() string { - return os.Args[0] + ` oci list-files --repository "Est et libero voluptatibus omnis molestiae." --tag "Excepturi perferendis dolores voluptas eius non."` + "\n" + - os.Args[0] + ` ks3 download-object --bucket "Omnis est natus exercitationem aliquid tempora cumque." --key "Reiciendis eligendi magnam officiis recusandae est fugiat."` + "\n" + + return os.Args[0] + ` health healthz` + "\n" + + os.Args[0] + ` oci list-files --repository "Excepturi perferendis dolores voluptas eius non." --tag "Est reprehenderit quibusdam eveniet velit."` + "\n" + + os.Args[0] + ` ks3 download-object --bucket "Reiciendis eligendi magnam officiis recusandae est fugiat." --key "Provident temporibus occaecati unde."` + "\n" + "" } @@ -45,6 +48,12 @@ func ParseEndpoint( restore bool, ) (goa.Endpoint, any, error) { var ( + healthFlags = flag.NewFlagSet("health", flag.ContinueOnError) + + healthHealthzFlags = flag.NewFlagSet("healthz", flag.ExitOnError) + + healthLivezFlags = flag.NewFlagSet("livez", flag.ExitOnError) + ociFlags = flag.NewFlagSet("oci", flag.ContinueOnError) ociListFilesFlags = flag.NewFlagSet("list-files", flag.ExitOnError) @@ -62,6 +71,10 @@ func ParseEndpoint( ks3DownloadObjectBucketFlag = ks3DownloadObjectFlags.String("bucket", "REQUIRED", "bucket name") ks3DownloadObjectKeyFlag = ks3DownloadObjectFlags.String("key", "REQUIRED", "object key") ) + healthFlags.Usage = healthUsage + healthHealthzFlags.Usage = healthHealthzUsage + healthLivezFlags.Usage = healthLivezUsage + ociFlags.Usage = ociUsage ociListFilesFlags.Usage = ociListFilesUsage ociDownloadFileFlags.Usage = ociDownloadFileUsage @@ -84,6 +97,8 @@ func ParseEndpoint( { svcn = flag.Arg(0) switch svcn { + case "health": + svcf = healthFlags case "oci": svcf = ociFlags case "ks3": @@ -103,6 +118,16 @@ func ParseEndpoint( { epn = svcf.Arg(0) switch svcn { + case "health": + switch epn { + case "healthz": + epf = healthHealthzFlags + + case "livez": + epf = healthLivezFlags + + } + case "oci": switch epn { case "list-files": @@ -140,6 +165,16 @@ func ParseEndpoint( ) { switch svcn { + case "health": + c := healthc.NewClient(scheme, host, doer, enc, dec, restore) + switch epn { + case "healthz": + endpoint = c.Healthz() + data = nil + case "livez": + endpoint = c.Livez() + data = nil + } case "oci": c := ocic.NewClient(scheme, host, doer, enc, dec, restore) switch epn { @@ -166,6 +201,40 @@ 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 +Usage: + %[1]s [globalflags] health COMMAND [flags] + +COMMAND: + healthz: Healthz implements healthz. + livez: Livez implements livez. + +Additional help: + %[1]s health COMMAND --help +`, os.Args[0]) +} +func healthHealthzUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health healthz + +Healthz implements healthz. + +Example: + %[1]s health healthz +`, os.Args[0]) +} + +func healthLivezUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health livez + +Livez implements livez. + +Example: + %[1]s health livez +`, os.Args[0]) +} + // ociUsage displays the usage of the oci command and its subcommands. func ociUsage() { fmt.Fprintf(os.Stderr, `OCI artifacts download service @@ -188,7 +257,7 @@ ListFiles implements list-files. -tag STRING: Example: - %[1]s oci list-files --repository "Est et libero voluptatibus omnis molestiae." --tag "Excepturi perferendis dolores voluptas eius non." + %[1]s oci list-files --repository "Excepturi perferendis dolores voluptas eius non." --tag "Est reprehenderit quibusdam eveniet velit." `, os.Args[0]) } @@ -201,7 +270,7 @@ DownloadFile implements download-file. -tag STRING: Example: - %[1]s oci download-file --repository "Dolores qui voluptas autem illo cum." --file "Quis maiores hic et commodi aut." --tag "Corrupti qui qui iusto." + %[1]s oci download-file --repository "Quis maiores hic et commodi aut." --file "Corrupti qui qui iusto." --tag "Enim animi exercitationem voluptate perferendis ut." `, os.Args[0]) } @@ -226,6 +295,6 @@ DownloadObject implements download-object. -key STRING: object key Example: - %[1]s ks3 download-object --bucket "Omnis est natus exercitationem aliquid tempora cumque." --key "Reiciendis eligendi magnam officiis recusandae est fugiat." + %[1]s ks3 download-object --bucket "Reiciendis eligendi magnam officiis recusandae est fugiat." --key "Provident temporibus occaecati unde." `, os.Args[0]) } diff --git a/dl/gen/http/health/client/cli.go b/dl/gen/http/health/client/cli.go new file mode 100644 index 0000000..d432dfd --- /dev/null +++ b/dl/gen/http/health/client/cli.go @@ -0,0 +1,8 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP client CLI support package +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package client diff --git a/dl/gen/http/health/client/client.go b/dl/gen/http/health/client/client.go new file mode 100644 index 0000000..3eaa821 --- /dev/null +++ b/dl/gen/http/health/client/client.go @@ -0,0 +1,93 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health client HTTP transport +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package client + +import ( + "context" + "net/http" + + goahttp "goa.design/goa/v3/http" + goa "goa.design/goa/v3/pkg" +) + +// Client lists the health service endpoint HTTP clients. +type Client struct { + // Healthz Doer is the HTTP client used to make requests to the healthz + // endpoint. + HealthzDoer goahttp.Doer + + // Livez Doer is the HTTP client used to make requests to the livez endpoint. + LivezDoer 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 health 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{ + HealthzDoer: doer, + LivezDoer: doer, + RestoreResponseBody: restoreBody, + scheme: scheme, + host: host, + decoder: dec, + encoder: enc, + } +} + +// Healthz returns an endpoint that makes HTTP requests to the health service +// healthz server. +func (c *Client) Healthz() goa.Endpoint { + var ( + decodeResponse = DecodeHealthzResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v any) (any, error) { + req, err := c.BuildHealthzRequest(ctx, v) + if err != nil { + return nil, err + } + resp, err := c.HealthzDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("health", "healthz", err) + } + return decodeResponse(resp) + } +} + +// Livez returns an endpoint that makes HTTP requests to the health service +// livez server. +func (c *Client) Livez() goa.Endpoint { + var ( + decodeResponse = DecodeLivezResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v any) (any, error) { + req, err := c.BuildLivezRequest(ctx, v) + if err != nil { + return nil, err + } + resp, err := c.LivezDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("health", "livez", err) + } + return decodeResponse(resp) + } +} diff --git a/dl/gen/http/health/client/encode_decode.go b/dl/gen/http/health/client/encode_decode.go new file mode 100644 index 0000000..cf9afdf --- /dev/null +++ b/dl/gen/http/health/client/encode_decode.go @@ -0,0 +1,118 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP client encoders and decoders +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + + goahttp "goa.design/goa/v3/http" +) + +// BuildHealthzRequest instantiates a HTTP request object with method and path +// set to call the "health" service "healthz" endpoint +func (c *Client) BuildHealthzRequest(ctx context.Context, v any) (*http.Request, error) { + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: HealthzHealthPath()} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("health", "healthz", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// DecodeHealthzResponse returns a decoder for responses returned by the health +// healthz endpoint. restoreBody controls whether the response body should be +// restored after having been read. +func DecodeHealthzResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (any, error) { + return func(resp *http.Response) (any, error) { + if restoreBody { + b, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body bool + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "healthz", err) + } + return body, nil + default: + body, _ := io.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("health", "healthz", resp.StatusCode, string(body)) + } + } +} + +// BuildLivezRequest instantiates a HTTP request object with method and path +// set to call the "health" service "livez" endpoint +func (c *Client) BuildLivezRequest(ctx context.Context, v any) (*http.Request, error) { + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: LivezHealthPath()} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("health", "livez", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// DecodeLivezResponse returns a decoder for responses returned by the health +// livez endpoint. restoreBody controls whether the response body should be +// restored after having been read. +func DecodeLivezResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (any, error) { + return func(resp *http.Response) (any, error) { + if restoreBody { + b, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body bool + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "livez", err) + } + return body, nil + default: + body, _ := io.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("health", "livez", resp.StatusCode, string(body)) + } + } +} diff --git a/dl/gen/http/health/client/paths.go b/dl/gen/http/health/client/paths.go new file mode 100644 index 0000000..8650f43 --- /dev/null +++ b/dl/gen/http/health/client/paths.go @@ -0,0 +1,18 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// HTTP request path constructors for the health service. +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package client + +// HealthzHealthPath returns the URL path to the health service healthz HTTP endpoint. +func HealthzHealthPath() string { + return "/healthz" +} + +// LivezHealthPath returns the URL path to the health service livez HTTP endpoint. +func LivezHealthPath() string { + return "/livez" +} diff --git a/dl/gen/http/health/client/types.go b/dl/gen/http/health/client/types.go new file mode 100644 index 0000000..ddeb953 --- /dev/null +++ b/dl/gen/http/health/client/types.go @@ -0,0 +1,8 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP client types +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package client diff --git a/dl/gen/http/health/server/encode_decode.go b/dl/gen/http/health/server/encode_decode.go new file mode 100644 index 0000000..0b17365 --- /dev/null +++ b/dl/gen/http/health/server/encode_decode.go @@ -0,0 +1,39 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP server encoders and decoders +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package server + +import ( + "context" + "net/http" + + goahttp "goa.design/goa/v3/http" +) + +// EncodeHealthzResponse returns an encoder for responses returned by the +// health healthz endpoint. +func EncodeHealthzResponse(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.(bool) + enc := encoder(ctx, w) + body := res + w.WriteHeader(http.StatusOK) + return enc.Encode(body) + } +} + +// EncodeLivezResponse returns an encoder for responses returned by the health +// livez endpoint. +func EncodeLivezResponse(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.(bool) + enc := encoder(ctx, w) + body := res + w.WriteHeader(http.StatusOK) + return enc.Encode(body) + } +} diff --git a/dl/gen/http/health/server/paths.go b/dl/gen/http/health/server/paths.go new file mode 100644 index 0000000..b5a0eb2 --- /dev/null +++ b/dl/gen/http/health/server/paths.go @@ -0,0 +1,18 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// HTTP request path constructors for the health service. +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package server + +// HealthzHealthPath returns the URL path to the health service healthz HTTP endpoint. +func HealthzHealthPath() string { + return "/healthz" +} + +// LivezHealthPath returns the URL path to the health service livez HTTP endpoint. +func LivezHealthPath() string { + return "/livez" +} diff --git a/dl/gen/http/health/server/server.go b/dl/gen/http/health/server/server.go new file mode 100644 index 0000000..fe75767 --- /dev/null +++ b/dl/gen/http/health/server/server.go @@ -0,0 +1,170 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP server +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package server + +import ( + "context" + "net/http" + + health "github.com/PingCAP-QE/ee-apps/dl/gen/health" + goahttp "goa.design/goa/v3/http" + goa "goa.design/goa/v3/pkg" +) + +// Server lists the health service endpoint HTTP handlers. +type Server struct { + Mounts []*MountPoint + Healthz http.Handler + Livez http.Handler +} + +// 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 health 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 *health.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(ctx context.Context, err error) goahttp.Statuser, +) *Server { + return &Server{ + Mounts: []*MountPoint{ + {"Healthz", "GET", "/healthz"}, + {"Livez", "GET", "/livez"}, + }, + Healthz: NewHealthzHandler(e.Healthz, mux, decoder, encoder, errhandler, formatter), + Livez: NewLivezHandler(e.Livez, mux, decoder, encoder, errhandler, formatter), + } +} + +// Service returns the name of the service served. +func (s *Server) Service() string { return "health" } + +// Use wraps the server handlers with the given middleware. +func (s *Server) Use(m func(http.Handler) http.Handler) { + s.Healthz = m(s.Healthz) + s.Livez = m(s.Livez) +} + +// MethodNames returns the methods served. +func (s *Server) MethodNames() []string { return health.MethodNames[:] } + +// Mount configures the mux to serve the health endpoints. +func Mount(mux goahttp.Muxer, h *Server) { + MountHealthzHandler(mux, h.Healthz) + MountLivezHandler(mux, h.Livez) +} + +// Mount configures the mux to serve the health endpoints. +func (s *Server) Mount(mux goahttp.Muxer) { + Mount(mux, s) +} + +// MountHealthzHandler configures the mux to serve the "health" service +// "healthz" endpoint. +func MountHealthzHandler(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", "/healthz", f) +} + +// NewHealthzHandler creates a HTTP handler which loads the HTTP request and +// calls the "health" service "healthz" endpoint. +func NewHealthzHandler( + 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(ctx context.Context, err error) goahttp.Statuser, +) http.Handler { + var ( + encodeResponse = EncodeHealthzResponse(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, "healthz") + ctx = context.WithValue(ctx, goa.ServiceKey, "health") + var err error + res, err := endpoint(ctx, nil) + 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) + } + }) +} + +// MountLivezHandler configures the mux to serve the "health" service "livez" +// endpoint. +func MountLivezHandler(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", "/livez", f) +} + +// NewLivezHandler creates a HTTP handler which loads the HTTP request and +// calls the "health" service "livez" endpoint. +func NewLivezHandler( + 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(ctx context.Context, err error) goahttp.Statuser, +) http.Handler { + var ( + encodeResponse = EncodeLivezResponse(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, "livez") + ctx = context.WithValue(ctx, goa.ServiceKey, "health") + var err error + res, err := endpoint(ctx, nil) + 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/dl/gen/http/health/server/types.go b/dl/gen/http/health/server/types.go new file mode 100644 index 0000000..2bdd6b6 --- /dev/null +++ b/dl/gen/http/health/server/types.go @@ -0,0 +1,8 @@ +// Code generated by goa v3.14.1, DO NOT EDIT. +// +// health HTTP server types +// +// Command: +// $ goa gen github.com/PingCAP-QE/ee-apps/dl/design + +package server diff --git a/dl/gen/http/openapi.json b/dl/gen/http/openapi.json index 760ccc8..cb26aa2 100644 --- a/dl/gen/http/openapi.json +++ b/dl/gen/http/openapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Download OCI artifacts Service","description":"Service for downloading files from OCI artifact","version":""},"host":"localhost:8000","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/oci-file/{repository}":{"get":{"tags":["oci"],"summary":"download-file oci","operationId":"oci#download-file","produces":["application/octet-stream"],"parameters":[{"name":"file","in":"query","description":"file name in OCI artifact","required":true,"type":"string"},{"name":"tag","in":"query","description":"OCI artifact tag","required":true,"type":"string"},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","type":"string"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","type":"int64"}}}},"schemes":["http"]}},"/oci-files/{repository}":{"get":{"tags":["oci"],"summary":"list-files oci","operationId":"oci#list-files","parameters":[{"name":"tag","in":"query","description":"OCI artifact tag","required":true,"type":"string"},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Provident temporibus occaecati unde."}}}},"schemes":["http"]}},"/s3-obj/{bucket}/{key}":{"get":{"tags":["ks3"],"summary":"download-object ks3","operationId":"ks3#download-object","produces":["application/octet-stream"],"parameters":[{"name":"bucket","in":"path","description":"bucket name","required":true,"type":"string"},{"name":"key","in":"path","description":"object key","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","type":"string"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","type":"int64"}}}},"schemes":["http"]}}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Download OCI artifacts Service","description":"Service for downloading files from OCI artifact","version":""},"host":"localhost:8000","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/healthz":{"get":{"tags":["health"],"summary":"healthz health","operationId":"health#healthz","responses":{"200":{"description":"OK response.","schema":{"type":"boolean"}}},"schemes":["http"]}},"/livez":{"get":{"tags":["health"],"summary":"livez health","operationId":"health#livez","responses":{"200":{"description":"OK response.","schema":{"type":"boolean"}}},"schemes":["http"]}},"/oci-file/{repository}":{"get":{"tags":["oci"],"summary":"download-file oci","operationId":"oci#download-file","produces":["application/octet-stream"],"parameters":[{"name":"file","in":"query","description":"file name in OCI artifact","required":true,"type":"string"},{"name":"tag","in":"query","description":"OCI artifact tag","required":true,"type":"string"},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","type":"string"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","type":"int64"}}}},"schemes":["http"]}},"/oci-files/{repository}":{"get":{"tags":["oci"],"summary":"list-files oci","operationId":"oci#list-files","parameters":[{"name":"tag","in":"query","description":"OCI artifact tag","required":true,"type":"string"},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Et aut labore veniam et maiores qui."}}}},"schemes":["http"]}},"/s3-obj/{bucket}/{key}":{"get":{"tags":["ks3"],"summary":"download-object ks3","operationId":"ks3#download-object","produces":["application/octet-stream"],"parameters":[{"name":"bucket","in":"path","description":"bucket name","required":true,"type":"string"},{"name":"key","in":"path","description":"object key","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","type":"string"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","type":"int64"}}}},"schemes":["http"]}}}} \ No newline at end of file diff --git a/dl/gen/http/openapi.yaml b/dl/gen/http/openapi.yaml index c0ec04f..9ecaf3e 100644 --- a/dl/gen/http/openapi.yaml +++ b/dl/gen/http/openapi.yaml @@ -13,6 +13,32 @@ produces: - application/xml - application/gob paths: + /healthz: + get: + tags: + - health + summary: healthz health + operationId: health#healthz + responses: + "200": + description: OK response. + schema: + type: boolean + schemes: + - http + /livez: + get: + tags: + - health + summary: livez health + operationId: health#livez + responses: + "200": + description: OK response. + schema: + type: boolean + schemes: + - http /oci-file/{repository}: get: tags: @@ -73,7 +99,7 @@ paths: type: array items: type: string - example: Provident temporibus occaecati unde. + example: Et aut labore veniam et maiores qui. schemes: - http /s3-obj/{bucket}/{key}: diff --git a/dl/gen/http/openapi3.json b/dl/gen/http/openapi3.json index 5498ff3..7da45d3 100644 --- a/dl/gen/http/openapi3.json +++ b/dl/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"Download OCI artifacts Service","description":"Service for downloading files from OCI artifact","version":"1.0"},"servers":[{"url":"http://localhost:8000"}],"paths":{"/oci-file/{repository}":{"get":{"tags":["oci"],"summary":"download-file oci","operationId":"oci#download-file","parameters":[{"name":"file","in":"query","description":"file name in OCI artifact","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"file name in OCI artifact","example":"Debitis nostrum maiores est."},"example":"Eligendi aut vero et neque odit."},{"name":"tag","in":"query","description":"OCI artifact tag","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"OCI artifact tag","example":"At aperiam laboriosam odio ut quam."},"example":"Assumenda aliquam est et aut."},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"schema":{"type":"string","description":"OCI artifact repository","example":"Magnam a corporis."},"example":"Sed nihil autem dolor blanditiis accusamus sit."}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","schema":{"type":"string","description":"Content-Disposition header for downloading","example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","schema":{"type":"integer","description":"Length is the downloaded content length in bytes.","example":4194304,"format":"int64"},"example":4194304}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}},"/oci-files/{repository}":{"get":{"tags":["oci"],"summary":"list-files oci","operationId":"oci#list-files","parameters":[{"name":"tag","in":"query","description":"OCI artifact tag","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"OCI artifact tag","example":"Recusandae dolor voluptas omnis ex."},"example":"Dolor itaque ullam."},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"schema":{"type":"string","description":"OCI artifact repository","example":"Repellendus id dolorem dolor quasi qui consectetur."},"example":"Et et fugit."}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Et aut labore veniam et maiores qui."},"example":["Incidunt qui itaque quos.","Nulla repudiandae magnam.","Nobis asperiores at non dignissimos error.","Repellendus iste nam."]},"example":["Aperiam sunt quam et asperiores cupiditate deserunt.","Et qui quo.","Fugiat tempore sapiente dolorem et laborum impedit.","Vero dolores amet possimus quasi libero nesciunt."]}}}}}},"/s3-obj/{bucket}/{key}":{"get":{"tags":["ks3"],"summary":"download-object ks3","operationId":"ks3#download-object","parameters":[{"name":"bucket","in":"path","description":"bucket name","required":true,"schema":{"type":"string","description":"bucket name","example":"Neque sunt ut repellendus."},"example":"Quaerat architecto."},{"name":"key","in":"path","description":"object key","required":true,"schema":{"type":"string","description":"object key","example":"Id et sit expedita."},"example":"Vero voluptatum perspiciatis omnis qui vel."}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","schema":{"type":"string","description":"Content-Disposition header for downloading","example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","schema":{"type":"integer","description":"Length is the downloaded content length in bytes.","example":4194304,"format":"int64"},"example":4194304}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}}},"components":{},"tags":[{"name":"oci","description":"OCI artifacts download service"},{"name":"ks3","description":"OCI artifacts download service"}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Download OCI artifacts Service","description":"Service for downloading files from OCI artifact","version":"1.0"},"servers":[{"url":"http://localhost:8000"}],"paths":{"/healthz":{"get":{"tags":["health"],"summary":"healthz health","operationId":"health#healthz","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"boolean","example":true},"example":true}}}}}},"/livez":{"get":{"tags":["health"],"summary":"livez health","operationId":"health#livez","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"boolean","example":true},"example":true}}}}}},"/oci-file/{repository}":{"get":{"tags":["oci"],"summary":"download-file oci","operationId":"oci#download-file","parameters":[{"name":"file","in":"query","description":"file name in OCI artifact","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"file name in OCI artifact","example":"Eligendi aut vero et neque odit."},"example":"At aperiam laboriosam odio ut quam."},{"name":"tag","in":"query","description":"OCI artifact tag","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"OCI artifact tag","example":"Assumenda aliquam est et aut."},"example":"Magnam a corporis."},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"schema":{"type":"string","description":"OCI artifact repository","example":"Sed nihil autem dolor blanditiis accusamus sit."},"example":"Neque sunt ut repellendus."}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","schema":{"type":"string","description":"Content-Disposition header for downloading","example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","schema":{"type":"integer","description":"Length is the downloaded content length in bytes.","example":4194304,"format":"int64"},"example":4194304}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}},"/oci-files/{repository}":{"get":{"tags":["oci"],"summary":"list-files oci","operationId":"oci#list-files","parameters":[{"name":"tag","in":"query","description":"OCI artifact tag","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"OCI artifact tag","example":"Dolor itaque ullam."},"example":"Repellendus id dolorem dolor quasi qui consectetur."},{"name":"repository","in":"path","description":"OCI artifact repository","required":true,"schema":{"type":"string","description":"OCI artifact repository","example":"Et et fugit."},"example":"Quia aperiam sunt quam et asperiores cupiditate."}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Qui itaque quos quaerat nulla."},"example":["Vel nobis asperiores at.","Dignissimos error et repellendus.","Nam quibusdam recusandae dolor voluptas."]},"example":["Et qui quo.","Fugiat tempore sapiente dolorem et laborum impedit.","Vero dolores amet possimus quasi libero nesciunt.","Debitis nostrum maiores est."]}}}}}},"/s3-obj/{bucket}/{key}":{"get":{"tags":["ks3"],"summary":"download-object ks3","operationId":"ks3#download-object","parameters":[{"name":"bucket","in":"path","description":"bucket name","required":true,"schema":{"type":"string","description":"bucket name","example":"Quaerat architecto."},"example":"Id et sit expedita."},{"name":"key","in":"path","description":"object key","required":true,"schema":{"type":"string","description":"object key","example":"Vero voluptatum perspiciatis omnis qui vel."},"example":"A at dolor soluta molestiae."}],"responses":{"200":{"description":"OK response.","headers":{"Content-Disposition":{"description":"Content-Disposition header for downloading","schema":{"type":"string","description":"Content-Disposition header for downloading","example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"example":"attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz"},"Content-Length":{"description":"Length is the downloaded content length in bytes.","schema":{"type":"integer","description":"Length is the downloaded content length in bytes.","example":4194304,"format":"int64"},"example":4194304}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}}},"components":{},"tags":[{"name":"health","description":"Health service"},{"name":"oci","description":"OCI artifacts download service"},{"name":"ks3","description":"OCI artifacts download service"}]} \ No newline at end of file diff --git a/dl/gen/http/openapi3.yaml b/dl/gen/http/openapi3.yaml index 2c38be8..d5ff94e 100644 --- a/dl/gen/http/openapi3.yaml +++ b/dl/gen/http/openapi3.yaml @@ -6,6 +6,36 @@ info: servers: - url: http://localhost:8000 paths: + /healthz: + get: + tags: + - health + summary: healthz health + operationId: health#healthz + responses: + "200": + description: OK response. + content: + application/json: + schema: + type: boolean + example: true + example: true + /livez: + get: + tags: + - health + summary: livez health + operationId: health#livez + responses: + "200": + description: OK response. + content: + application/json: + schema: + type: boolean + example: true + example: true /oci-file/{repository}: get: tags: @@ -21,8 +51,8 @@ paths: schema: type: string description: file name in OCI artifact - example: Debitis nostrum maiores est. - example: Eligendi aut vero et neque odit. + example: Eligendi aut vero et neque odit. + example: At aperiam laboriosam odio ut quam. - name: tag in: query description: OCI artifact tag @@ -31,8 +61,8 @@ paths: schema: type: string description: OCI artifact tag - example: At aperiam laboriosam odio ut quam. - example: Assumenda aliquam est et aut. + example: Assumenda aliquam est et aut. + example: Magnam a corporis. - name: repository in: path description: OCI artifact repository @@ -40,8 +70,8 @@ paths: schema: type: string description: OCI artifact repository - example: Magnam a corporis. - example: Sed nihil autem dolor blanditiis accusamus sit. + example: Sed nihil autem dolor blanditiis accusamus sit. + example: Neque sunt ut repellendus. responses: "200": description: OK response. @@ -81,8 +111,8 @@ paths: schema: type: string description: OCI artifact tag - example: Recusandae dolor voluptas omnis ex. - example: Dolor itaque ullam. + example: Dolor itaque ullam. + example: Repellendus id dolorem dolor quasi qui consectetur. - name: repository in: path description: OCI artifact repository @@ -90,8 +120,8 @@ paths: schema: type: string description: OCI artifact repository - example: Repellendus id dolorem dolor quasi qui consectetur. - example: Et et fugit. + example: Et et fugit. + example: Quia aperiam sunt quam et asperiores cupiditate. responses: "200": description: OK response. @@ -101,17 +131,16 @@ paths: type: array items: type: string - example: Et aut labore veniam et maiores qui. + example: Qui itaque quos quaerat nulla. example: - - Incidunt qui itaque quos. - - Nulla repudiandae magnam. - - Nobis asperiores at non dignissimos error. - - Repellendus iste nam. + - Vel nobis asperiores at. + - Dignissimos error et repellendus. + - Nam quibusdam recusandae dolor voluptas. example: - - Aperiam sunt quam et asperiores cupiditate deserunt. - Et qui quo. - Fugiat tempore sapiente dolorem et laborum impedit. - Vero dolores amet possimus quasi libero nesciunt. + - Debitis nostrum maiores est. /s3-obj/{bucket}/{key}: get: tags: @@ -126,8 +155,8 @@ paths: schema: type: string description: bucket name - example: Neque sunt ut repellendus. - example: Quaerat architecto. + example: Quaerat architecto. + example: Id et sit expedita. - name: key in: path description: object key @@ -135,8 +164,8 @@ paths: schema: type: string description: object key - example: Id et sit expedita. - example: Vero voluptatum perspiciatis omnis qui vel. + example: Vero voluptatum perspiciatis omnis qui vel. + example: A at dolor soluta molestiae. responses: "200": description: OK response. @@ -163,6 +192,8 @@ paths: format: binary components: {} tags: + - name: health + description: Health service - name: oci description: OCI artifacts download service - name: ks3 diff --git a/dl/health.go b/dl/health.go new file mode 100644 index 0000000..f79f6b1 --- /dev/null +++ b/dl/health.go @@ -0,0 +1,31 @@ +package dl + +import ( + "context" + "log" + + health "github.com/PingCAP-QE/ee-apps/dl/gen/health" +) + +// health service example implementation. +// The example methods log the requests and return zero values. +type healthsrvc struct { + logger *log.Logger +} + +// NewHealth returns the health service implementation. +func NewHealth(logger *log.Logger) health.Service { + return &healthsrvc{logger} +} + +// Healthz implements healthz. +func (s *healthsrvc) Healthz(ctx context.Context) (res bool, err error) { + s.logger.Print("health.healthz") + return true, nil +} + +// Livez implements livez. +func (s *healthsrvc) Livez(ctx context.Context) (res bool, err error) { + s.logger.Print("health.livez") + return true, nil +}