Merged in feature/healthmove (pull request #165)
Move health endpoint from OpenAPI spec to direct implementation * Move health endpoint from OpenAPI spec to direct implementation - Removed HealthService tag from OpenAPI spec - Removed /health path from OpenAPI spec - Removed health.go and health_test.go files from api/queryAPI - Added direct health endpoint in internal/server/api/listener.go - Updated validator options to skip validation for the /health endpoint - Added test for health endpoint in internal/server/api/listener_test.go - Regenerated API code from the updated OpenAPI spec
This commit is contained in:
@@ -0,0 +1,142 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
## General rules DO NOT VIOLATE
|
||||||
|
NEVER create mock data or simplified components unless explicitly told to do so
|
||||||
|
NEVER replace existing complex components with simplified versions - always fix the actual problem or the feature that was requested.
|
||||||
|
ALWAYS work with the existing codebase - do not create new simplified alternatives
|
||||||
|
ALWAYS find and fix the root cause of issues instead of creating workarounds
|
||||||
|
When debugging issues, focus on fixing the existing implementation, not replacing it
|
||||||
|
When something doesn't work, debug and fix it - don't start over with a simple version
|
||||||
|
Don’t build things I am not specifically asking for unless its required to build the thing I am asking for.
|
||||||
|
When asked to make unit tests avoid mocks and use the actual thing that is being tested when reasonable.
|
||||||
|
|
||||||
|
## Essential Commands
|
||||||
|
|
||||||
|
### Development Setup
|
||||||
|
- `devbox shell` - Enter development environment (Nix-based)
|
||||||
|
- `touch .env` - Create environment variables file
|
||||||
|
- `task fullsuite` - Complete development workflow (generate, build, lint, test)
|
||||||
|
|
||||||
|
### Core Development Tasks
|
||||||
|
- `task generate` - Generate all code (DB queries via SQLC, OpenAPI clients/servers, mocks, docs)
|
||||||
|
- `task build` - Build Docker image
|
||||||
|
- `task lint` - Run all linting (Go, YAML, JSON, Docker, OpenAPI)
|
||||||
|
- `task go:lint -- --fix` - Fix automatically fixable linting issues in Go code
|
||||||
|
- `task test:functional` - Run full test suite with 80% coverage threshold
|
||||||
|
- `task precommit` - Pre-commit checks for CI/CD readiness
|
||||||
|
|
||||||
|
### Testing Commands
|
||||||
|
- `task test:unit:short` - Quick unit tests
|
||||||
|
- `task test:race` - Race condition detection
|
||||||
|
- `task test:perf` - Performance analysis with slowest test reporting
|
||||||
|
- `task test:mem` - Memory usage profiling
|
||||||
|
- `task test:bench` - Benchmark execution
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
### System Design
|
||||||
|
This is a **document processing and query orchestration platform** with microservices architecture using:
|
||||||
|
- **Event-driven processing** via AWS SQS queues
|
||||||
|
- **RESTful API** (queryAPI on port 8080) for external interactions
|
||||||
|
- **Runner services** (ports 8081-8090) as queue consumers
|
||||||
|
- **PostgreSQL** with migration-driven schema management
|
||||||
|
- **AWS services** (S3, SQS, Textract, Cognito) for cloud functionality
|
||||||
|
|
||||||
|
### Document Processing Pipeline
|
||||||
|
1. **Upload** → S3 storage → storeEventRunner
|
||||||
|
2. **Init** → Validation/deduplication → docInitRunner
|
||||||
|
3. **Sync** → Client eligibility → docSyncRunner
|
||||||
|
4. **Clean** → Content processing → docCleanRunner
|
||||||
|
5. **Text Extraction** → AWS Textract OCR → docTextRunner
|
||||||
|
6. **Query Processing** → Custom queries → queryRunner
|
||||||
|
7. **Export** → Result generation
|
||||||
|
|
||||||
|
### Core Entities
|
||||||
|
- **Client**: Customer configurations with document sets and permissions
|
||||||
|
- **Collector**: Query collection specifications per client
|
||||||
|
- **Query**: Data processing blocks with dependency chains
|
||||||
|
- **Document**: Uploaded files with processing state tracking
|
||||||
|
- **Export**: Manual result output processes
|
||||||
|
|
||||||
|
### Service Architecture
|
||||||
|
- **queryAPI** (8080): Main REST API with OpenAPI-generated handlers
|
||||||
|
- **Runners** (8081-8090): Queue-based processing services implementing `Controller` interface
|
||||||
|
- Each runner consumes from specific SQS queues
|
||||||
|
- Stateless processing with database persistence
|
||||||
|
- Prometheus metrics integration
|
||||||
|
|
||||||
|
## Development Patterns
|
||||||
|
|
||||||
|
### Code Generation
|
||||||
|
All code generation happens via `task generate`:
|
||||||
|
- **SQLC**: Database queries from `internal/database/queries/*.sql`
|
||||||
|
- **OpenAPI**: API clients/servers from `serviceAPIs/*.yaml`
|
||||||
|
- **Mockery**: Test mocks for interfaces
|
||||||
|
- **gomarkdoc**: Documentation generation
|
||||||
|
|
||||||
|
### Testing Strategy
|
||||||
|
- **Testcontainers**: Docker-based integration testing for database/queue interactions
|
||||||
|
- **80% coverage threshold** (60% function coverage) enforced
|
||||||
|
- **Private test files**: Use `*private_test.go` for internal testing
|
||||||
|
- **Mock interfaces**: Auto-generated in `mocks/` directory
|
||||||
|
|
||||||
|
### Project Structure
|
||||||
|
Follows Go Standard Project Layout:
|
||||||
|
- `cmd/`: Application entry points (main.go files)
|
||||||
|
- `internal/`: Private application code
|
||||||
|
- `api/`: Generated API server implementations
|
||||||
|
- `pkg/`: Generated API client libraries
|
||||||
|
- `mocks/`: Auto-generated test mocks
|
||||||
|
|
||||||
|
### Naming Conventions
|
||||||
|
- **Service**: Commands deployed as APIs (e.g., queryAPI)
|
||||||
|
- **Runner**: Commands deployed as queue consumers (e.g., docTextRunner)
|
||||||
|
- **API naming**: `<functionality>API` format
|
||||||
|
- **Runner naming**: `<functionality>Runner` format
|
||||||
|
|
||||||
|
### Environment Configuration
|
||||||
|
Environment variable hierarchy (first overrides subsequent):
|
||||||
|
1. `devbox.json` "env" section
|
||||||
|
2. `devbox.json` "init_hook" exports
|
||||||
|
3. `.env` file variables
|
||||||
|
|
||||||
|
### Authentication & Authorization
|
||||||
|
- **AWS Cognito**: JWT-based authentication
|
||||||
|
- **Permit.io**: RBAC integration for fine-grained permissions
|
||||||
|
- Middleware handles token validation and permission checking
|
||||||
|
|
||||||
|
## Key Dependencies
|
||||||
|
|
||||||
|
### Core Technologies
|
||||||
|
- **Go 1.24**: Primary language
|
||||||
|
- **PostgreSQL**: Database with pgx driver
|
||||||
|
- **Echo v4**: HTTP framework with middleware
|
||||||
|
- **Testcontainers**: Integration testing
|
||||||
|
- **AWS SDK v2**: Cloud service integration
|
||||||
|
|
||||||
|
### Code Quality Tools
|
||||||
|
- **golangci-lint**: Go linting
|
||||||
|
- **yamllint**: YAML validation
|
||||||
|
- **Task**: Build automation
|
||||||
|
- **devbox**: Development environment
|
||||||
|
|
||||||
|
## Quick Start for New Features
|
||||||
|
|
||||||
|
### Adding New API Endpoint
|
||||||
|
1. Modify `serviceAPIs/queryAPI.yaml` OpenAPI specification
|
||||||
|
2. Run `task generate` to regenerate API code
|
||||||
|
3. Implement handlers in `api/queryAPI/`
|
||||||
|
4. Add tests following existing patterns
|
||||||
|
|
||||||
|
### Adding New Queue Consumer
|
||||||
|
1. Create `api/<runnerName>/runner.go` implementing `Controller` interface
|
||||||
|
2. Create `cmd/<runnerName>/main.go` entry point
|
||||||
|
3. Add queue configuration in `internal/serviceconfig/queue/`
|
||||||
|
4. Add to docker-compose and deployment configurations
|
||||||
|
|
||||||
|
### Database Changes
|
||||||
|
1. Add migration files in `internal/database/migrations/`
|
||||||
|
2. Add queries in `internal/database/queries/`
|
||||||
|
3. Run `task db:generate` to regenerate Go code
|
||||||
|
4. Update repository layer as needed
|
||||||
+75
-89
@@ -428,9 +428,6 @@ type ServerInterface interface {
|
|||||||
// Check export state.
|
// Check export state.
|
||||||
// (GET /export/{id})
|
// (GET /export/{id})
|
||||||
ExportState(ctx echo.Context, id ExportID) error
|
ExportState(ctx echo.Context, id ExportID) error
|
||||||
// Provide health endpoint
|
|
||||||
// (GET /health)
|
|
||||||
IsHealthy(ctx echo.Context) error
|
|
||||||
// Get the home page menu
|
// Get the home page menu
|
||||||
// (GET /home)
|
// (GET /home)
|
||||||
GetHomePage(ctx echo.Context) error
|
GetHomePage(ctx echo.Context) error
|
||||||
@@ -656,15 +653,6 @@ func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHealthy converts echo context to params.
|
|
||||||
func (w *ServerInterfaceWrapper) IsHealthy(ctx echo.Context) error {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// Invoke the callback with all the unmarshaled arguments
|
|
||||||
err = w.Handler.IsHealthy(ctx)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHomePage converts echo context to params.
|
// GetHomePage converts echo context to params.
|
||||||
func (w *ServerInterfaceWrapper) GetHomePage(ctx echo.Context) error {
|
func (w *ServerInterfaceWrapper) GetHomePage(ctx echo.Context) error {
|
||||||
var err error
|
var err error
|
||||||
@@ -838,7 +826,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
|
|||||||
router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId)
|
router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId)
|
||||||
router.GET(baseURL+"/document/:id", wrapper.GetDocument)
|
router.GET(baseURL+"/document/:id", wrapper.GetDocument)
|
||||||
router.GET(baseURL+"/export/:id", wrapper.ExportState)
|
router.GET(baseURL+"/export/:id", wrapper.ExportState)
|
||||||
router.GET(baseURL+"/health", wrapper.IsHealthy)
|
|
||||||
router.GET(baseURL+"/home", wrapper.GetHomePage)
|
router.GET(baseURL+"/home", wrapper.GetHomePage)
|
||||||
router.GET(baseURL+"/login", wrapper.Login)
|
router.GET(baseURL+"/login", wrapper.Login)
|
||||||
router.GET(baseURL+"/login-callback", wrapper.LoginCallback)
|
router.GET(baseURL+"/login-callback", wrapper.LoginCallback)
|
||||||
@@ -854,82 +841,81 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
|
|||||||
// Base64 encoded, gzipped, json marshaled Swagger object
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
||||||
var swaggerSpec = []string{
|
var swaggerSpec = []string{
|
||||||
|
|
||||||
"H4sIAAAAAAAC/+xceW8juXL/KkTnAQF2dUs+gyDxs2d2tJhrbU/eS8aOQXWXJO52kxqSbY9m4O8e8OqT",
|
"H4sIAAAAAAAC/+xceW8juXL/KkTnAQF2dUs+gyDxs2d2tJhrbU/eS8aOQHWXJO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yenj7eP/BQAA///MtX56kW0AAA==",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSwagger returns the content of the embedded swagger specification file
|
// GetSwagger returns the content of the embedded swagger specification file
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package queryapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s *Controllers) IsHealthy(ctx echo.Context) error {
|
|
||||||
return ctx.NoContent(http.StatusOK)
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package queryapi_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
queryapi "queryorchestration/api/queryAPI"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIsHealthy(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
cfg := &ControllerConfig{}
|
|
||||||
|
|
||||||
svc := createControllerServices(cfg)
|
|
||||||
cons := queryapi.NewControllers(svc)
|
|
||||||
|
|
||||||
ctx, rec := createContext(t)
|
|
||||||
|
|
||||||
err := cons.IsHealthy(ctx)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, http.StatusOK, rec.Code)
|
|
||||||
}
|
|
||||||
+32
@@ -161,6 +161,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"github:NixOS/nixpkgs/nixpkgs-unstable": {
|
||||||
|
"last_modified": "2025-06-10T02:39:58Z",
|
||||||
|
"resolved": "github:NixOS/nixpkgs/cdc68935eba9f86d155585fdf6f17af6824f38ac?lastModified=1749523198&narHash=sha256-How2kQw0psKmCdXgojc95Sf3K5maHB3qfINxTZFCAPM%3D"
|
||||||
|
},
|
||||||
|
"glibcLocales@latest": {
|
||||||
|
"last_modified": "2025-05-16T20:19:48Z",
|
||||||
|
"resolved": "github:NixOS/nixpkgs/12a55407652e04dcf2309436eb06fef0d3713ef3#glibcLocales",
|
||||||
|
"source": "devbox-search",
|
||||||
|
"version": "2.40-66",
|
||||||
|
"systems": {
|
||||||
|
"aarch64-linux": {
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "out",
|
||||||
|
"path": "/nix/store/2hb8s2i45cx30qqhayzzsfbg12k8d8fs-glibc-locales-2.40-66",
|
||||||
|
"default": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"store_path": "/nix/store/2hb8s2i45cx30qqhayzzsfbg12k8d8fs-glibc-locales-2.40-66"
|
||||||
|
},
|
||||||
|
"x86_64-linux": {
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "out",
|
||||||
|
"path": "/nix/store/d91i3lzpkii5kabfx1kxvl3banc47min-glibc-locales-2.40-66",
|
||||||
|
"default": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"store_path": "/nix/store/d91i3lzpkii5kabfx1kxvl3banc47min-glibc-locales-2.40-66"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"go-migrate@4.18.1": {
|
"go-migrate@4.18.1": {
|
||||||
"last_modified": "2024-12-23T21:10:33Z",
|
"last_modified": "2024-12-23T21:10:33Z",
|
||||||
"resolved": "github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d#go-migrate",
|
"resolved": "github:NixOS/nixpkgs/de1864217bfa9b5845f465e771e0ecb48b30e02d#go-migrate",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -212,6 +213,11 @@ func New(ctx context.Context, cfg Config) (*Server, error) {
|
|||||||
e.Use(echoprometheus.NewMiddleware("echo"))
|
e.Use(echoprometheus.NewMiddleware("echo"))
|
||||||
e.GET("/metrics", echoprometheus.NewHandler())
|
e.GET("/metrics", echoprometheus.NewHandler())
|
||||||
|
|
||||||
|
// Health endpoint
|
||||||
|
e.GET("/health", func(c echo.Context) error {
|
||||||
|
return c.NoContent(http.StatusOK)
|
||||||
|
})
|
||||||
|
|
||||||
e.Use(getSlogCustomEchoMiddleware(cfg.GetLogger()))
|
e.Use(getSlogCustomEchoMiddleware(cfg.GetLogger()))
|
||||||
e.Use(middleware.Recover())
|
e.Use(middleware.Recover())
|
||||||
e.Use(middleware.CORS())
|
e.Use(middleware.CORS())
|
||||||
@@ -247,7 +253,8 @@ func setOapi(e *echo.Echo, opnapi *openapi3.T) error {
|
|||||||
validatorOptions := &oapimiddleware.Options{
|
validatorOptions := &oapimiddleware.Options{
|
||||||
Skipper: func(c echo.Context) bool {
|
Skipper: func(c echo.Context) bool {
|
||||||
return len(c.Path()) >= 8 && (c.Path()[:8] == "/swagger" ||
|
return len(c.Path()) >= 8 && (c.Path()[:8] == "/swagger" ||
|
||||||
c.Path()[:8] == "/metrics")
|
c.Path()[:8] == "/metrics") ||
|
||||||
|
c.Path() == "/health"
|
||||||
},
|
},
|
||||||
Options: openapi3filter.Options{
|
Options: openapi3filter.Options{
|
||||||
AuthenticationFunc: openapi3filter.NoopAuthenticationFunc,
|
AuthenticationFunc: openapi3filter.NoopAuthenticationFunc,
|
||||||
|
|||||||
@@ -82,6 +82,29 @@ func TestGetRouter(t *testing.T) {
|
|||||||
assert.Equal(t, r, c.Router)
|
assert.Equal(t, r, c.Router)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHealthEndpoint(t *testing.T) {
|
||||||
|
// Create a new Echo instance
|
||||||
|
e := echo.New()
|
||||||
|
|
||||||
|
// Register health endpoint
|
||||||
|
e.GET("/health", func(c echo.Context) error {
|
||||||
|
return c.NoContent(http.StatusOK)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Create a request to the health endpoint
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/health", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
|
// Serve the request
|
||||||
|
e.ServeHTTP(rec, req)
|
||||||
|
|
||||||
|
// Assert the response status code
|
||||||
|
assert.Equal(t, http.StatusOK, rec.Code)
|
||||||
|
|
||||||
|
// Assert the response body is empty
|
||||||
|
assert.Empty(t, rec.Body.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetSlogCustomEchoMiddleware(t *testing.T) {
|
func TestGetSlogCustomEchoMiddleware(t *testing.T) {
|
||||||
l := &logger.TestLogger{
|
l := &logger.TestLogger{
|
||||||
T: t,
|
T: t,
|
||||||
|
|||||||
@@ -841,79 +841,6 @@ func (_c *MockClientInterface_GetStatusByClientId_Call) RunAndReturn(run func(co
|
|||||||
return _c
|
return _c
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHealthy provides a mock function with given fields: ctx, reqEditors
|
|
||||||
func (_m *MockClientInterface) IsHealthy(ctx context.Context, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) {
|
|
||||||
_va := make([]interface{}, len(reqEditors))
|
|
||||||
for _i := range reqEditors {
|
|
||||||
_va[_i] = reqEditors[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, ctx)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
if len(ret) == 0 {
|
|
||||||
panic("no return value specified for IsHealthy")
|
|
||||||
}
|
|
||||||
|
|
||||||
var r0 *http.Response
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) (*http.Response, error)); ok {
|
|
||||||
return rf(ctx, reqEditors...)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) *http.Response); ok {
|
|
||||||
r0 = rf(ctx, reqEditors...)
|
|
||||||
} else {
|
|
||||||
if ret.Get(0) != nil {
|
|
||||||
r0 = ret.Get(0).(*http.Response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(context.Context, ...queryapi.RequestEditorFn) error); ok {
|
|
||||||
r1 = rf(ctx, reqEditors...)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockClientInterface_IsHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHealthy'
|
|
||||||
type MockClientInterface_IsHealthy_Call struct {
|
|
||||||
*mock.Call
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsHealthy is a helper method to define mock.On call
|
|
||||||
// - ctx context.Context
|
|
||||||
// - reqEditors ...queryapi.RequestEditorFn
|
|
||||||
func (_e *MockClientInterface_Expecter) IsHealthy(ctx interface{}, reqEditors ...interface{}) *MockClientInterface_IsHealthy_Call {
|
|
||||||
return &MockClientInterface_IsHealthy_Call{Call: _e.mock.On("IsHealthy",
|
|
||||||
append([]interface{}{ctx}, reqEditors...)...)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientInterface_IsHealthy_Call) Run(run func(ctx context.Context, reqEditors ...queryapi.RequestEditorFn)) *MockClientInterface_IsHealthy_Call {
|
|
||||||
_c.Call.Run(func(args mock.Arguments) {
|
|
||||||
variadicArgs := make([]queryapi.RequestEditorFn, len(args)-1)
|
|
||||||
for i, a := range args[1:] {
|
|
||||||
if a != nil {
|
|
||||||
variadicArgs[i] = a.(queryapi.RequestEditorFn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
run(args[0].(context.Context), variadicArgs...)
|
|
||||||
})
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientInterface_IsHealthy_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_IsHealthy_Call {
|
|
||||||
_c.Call.Return(_a0, _a1)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientInterface_IsHealthy_Call) RunAndReturn(run func(context.Context, ...queryapi.RequestEditorFn) (*http.Response, error)) *MockClientInterface_IsHealthy_Call {
|
|
||||||
_c.Call.Return(run)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListDocumentsByClientId provides a mock function with given fields: ctx, id, reqEditors
|
// ListDocumentsByClientId provides a mock function with given fields: ctx, id, reqEditors
|
||||||
func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id queryapi.ClientID, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) {
|
func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id queryapi.ClientID, reqEditors ...queryapi.RequestEditorFn) (*http.Response, error) {
|
||||||
_va := make([]interface{}, len(reqEditors))
|
_va := make([]interface{}, len(reqEditors))
|
||||||
|
|||||||
@@ -839,79 +839,6 @@ func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call)
|
|||||||
return _c
|
return _c
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHealthyWithResponse provides a mock function with given fields: ctx, reqEditors
|
|
||||||
func (_m *MockClientWithResponsesInterface) IsHealthyWithResponse(ctx context.Context, reqEditors ...queryapi.RequestEditorFn) (*queryapi.IsHealthyResponse, error) {
|
|
||||||
_va := make([]interface{}, len(reqEditors))
|
|
||||||
for _i := range reqEditors {
|
|
||||||
_va[_i] = reqEditors[_i]
|
|
||||||
}
|
|
||||||
var _ca []interface{}
|
|
||||||
_ca = append(_ca, ctx)
|
|
||||||
_ca = append(_ca, _va...)
|
|
||||||
ret := _m.Called(_ca...)
|
|
||||||
|
|
||||||
if len(ret) == 0 {
|
|
||||||
panic("no return value specified for IsHealthyWithResponse")
|
|
||||||
}
|
|
||||||
|
|
||||||
var r0 *queryapi.IsHealthyResponse
|
|
||||||
var r1 error
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) (*queryapi.IsHealthyResponse, error)); ok {
|
|
||||||
return rf(ctx, reqEditors...)
|
|
||||||
}
|
|
||||||
if rf, ok := ret.Get(0).(func(context.Context, ...queryapi.RequestEditorFn) *queryapi.IsHealthyResponse); ok {
|
|
||||||
r0 = rf(ctx, reqEditors...)
|
|
||||||
} else {
|
|
||||||
if ret.Get(0) != nil {
|
|
||||||
r0 = ret.Get(0).(*queryapi.IsHealthyResponse)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if rf, ok := ret.Get(1).(func(context.Context, ...queryapi.RequestEditorFn) error); ok {
|
|
||||||
r1 = rf(ctx, reqEditors...)
|
|
||||||
} else {
|
|
||||||
r1 = ret.Error(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r0, r1
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockClientWithResponsesInterface_IsHealthyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHealthyWithResponse'
|
|
||||||
type MockClientWithResponsesInterface_IsHealthyWithResponse_Call struct {
|
|
||||||
*mock.Call
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsHealthyWithResponse is a helper method to define mock.On call
|
|
||||||
// - ctx context.Context
|
|
||||||
// - reqEditors ...queryapi.RequestEditorFn
|
|
||||||
func (_e *MockClientWithResponsesInterface_Expecter) IsHealthyWithResponse(ctx interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_IsHealthyWithResponse_Call {
|
|
||||||
return &MockClientWithResponsesInterface_IsHealthyWithResponse_Call{Call: _e.mock.On("IsHealthyWithResponse",
|
|
||||||
append([]interface{}{ctx}, reqEditors...)...)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientWithResponsesInterface_IsHealthyWithResponse_Call) Run(run func(ctx context.Context, reqEditors ...queryapi.RequestEditorFn)) *MockClientWithResponsesInterface_IsHealthyWithResponse_Call {
|
|
||||||
_c.Call.Run(func(args mock.Arguments) {
|
|
||||||
variadicArgs := make([]queryapi.RequestEditorFn, len(args)-1)
|
|
||||||
for i, a := range args[1:] {
|
|
||||||
if a != nil {
|
|
||||||
variadicArgs[i] = a.(queryapi.RequestEditorFn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
run(args[0].(context.Context), variadicArgs...)
|
|
||||||
})
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientWithResponsesInterface_IsHealthyWithResponse_Call) Return(_a0 *queryapi.IsHealthyResponse, _a1 error) *MockClientWithResponsesInterface_IsHealthyWithResponse_Call {
|
|
||||||
_c.Call.Return(_a0, _a1)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_c *MockClientWithResponsesInterface_IsHealthyWithResponse_Call) RunAndReturn(run func(context.Context, ...queryapi.RequestEditorFn) (*queryapi.IsHealthyResponse, error)) *MockClientWithResponsesInterface_IsHealthyWithResponse_Call {
|
|
||||||
_c.Call.Return(run)
|
|
||||||
return _c
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListDocumentsByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors
|
// ListDocumentsByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors
|
||||||
func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse(ctx context.Context, id queryapi.ClientID, reqEditors ...queryapi.RequestEditorFn) (*queryapi.ListDocumentsByClientIdResponse, error) {
|
func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse(ctx context.Context, id queryapi.ClientID, reqEditors ...queryapi.RequestEditorFn) (*queryapi.ListDocumentsByClientIdResponse, error) {
|
||||||
_va := make([]interface{}, len(reqEditors))
|
_va := make([]interface{}, len(reqEditors))
|
||||||
|
|||||||
@@ -505,9 +505,6 @@ type ClientInterface interface {
|
|||||||
// ExportState request
|
// ExportState request
|
||||||
ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||||
|
|
||||||
// IsHealthy request
|
|
||||||
IsHealthy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
||||||
|
|
||||||
// GetHomePage request
|
// GetHomePage request
|
||||||
GetHomePage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
GetHomePage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||||
|
|
||||||
@@ -722,18 +719,6 @@ func (c *Client) ExportState(ctx context.Context, id ExportID, reqEditors ...Req
|
|||||||
return c.Client.Do(req)
|
return c.Client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) IsHealthy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
||||||
req, err := NewIsHealthyRequest(c.Server)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req = req.WithContext(ctx)
|
|
||||||
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return c.Client.Do(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetHomePage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
func (c *Client) GetHomePage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||||
req, err := NewGetHomePageRequest(c.Server)
|
req, err := NewGetHomePageRequest(c.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1299,33 +1284,6 @@ func NewExportStateRequest(server string, id ExportID) (*http.Request, error) {
|
|||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIsHealthyRequest generates requests for IsHealthy
|
|
||||||
func NewIsHealthyRequest(server string) (*http.Request, error) {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
serverURL, err := url.Parse(server)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
operationPath := fmt.Sprintf("/health")
|
|
||||||
if operationPath[0] == '/' {
|
|
||||||
operationPath = "." + operationPath
|
|
||||||
}
|
|
||||||
|
|
||||||
queryURL, err := serverURL.Parse(operationPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewGetHomePageRequest generates requests for GetHomePage
|
// NewGetHomePageRequest generates requests for GetHomePage
|
||||||
func NewGetHomePageRequest(server string) (*http.Request, error) {
|
func NewGetHomePageRequest(server string) (*http.Request, error) {
|
||||||
var err error
|
var err error
|
||||||
@@ -1743,9 +1701,6 @@ type ClientWithResponsesInterface interface {
|
|||||||
// ExportStateWithResponse request
|
// ExportStateWithResponse request
|
||||||
ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error)
|
ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error)
|
||||||
|
|
||||||
// IsHealthyWithResponse request
|
|
||||||
IsHealthyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsHealthyResponse, error)
|
|
||||||
|
|
||||||
// GetHomePageWithResponse request
|
// GetHomePageWithResponse request
|
||||||
GetHomePageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHomePageResponse, error)
|
GetHomePageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHomePageResponse, error)
|
||||||
|
|
||||||
@@ -2063,31 +2018,6 @@ func (r ExportStateResponse) StatusCode() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type IsHealthyResponse struct {
|
|
||||||
Body []byte
|
|
||||||
HTTPResponse *http.Response
|
|
||||||
JSON400 *InvalidRequest
|
|
||||||
JSON401 *Unauthorized
|
|
||||||
JSON429 *TooManyRequests
|
|
||||||
JSON500 *InternalError
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status returns HTTPResponse.Status
|
|
||||||
func (r IsHealthyResponse) Status() string {
|
|
||||||
if r.HTTPResponse != nil {
|
|
||||||
return r.HTTPResponse.Status
|
|
||||||
}
|
|
||||||
return http.StatusText(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusCode returns HTTPResponse.StatusCode
|
|
||||||
func (r IsHealthyResponse) StatusCode() int {
|
|
||||||
if r.HTTPResponse != nil {
|
|
||||||
return r.HTTPResponse.StatusCode
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetHomePageResponse struct {
|
type GetHomePageResponse struct {
|
||||||
Body []byte
|
Body []byte
|
||||||
HTTPResponse *http.Response
|
HTTPResponse *http.Response
|
||||||
@@ -2448,15 +2378,6 @@ func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id Ex
|
|||||||
return ParseExportStateResponse(rsp)
|
return ParseExportStateResponse(rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsHealthyWithResponse request returning *IsHealthyResponse
|
|
||||||
func (c *ClientWithResponses) IsHealthyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*IsHealthyResponse, error) {
|
|
||||||
rsp, err := c.IsHealthy(ctx, reqEditors...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ParseIsHealthyResponse(rsp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHomePageWithResponse request returning *GetHomePageResponse
|
// GetHomePageWithResponse request returning *GetHomePageResponse
|
||||||
func (c *ClientWithResponses) GetHomePageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHomePageResponse, error) {
|
func (c *ClientWithResponses) GetHomePageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHomePageResponse, error) {
|
||||||
rsp, err := c.GetHomePage(ctx, reqEditors...)
|
rsp, err := c.GetHomePage(ctx, reqEditors...)
|
||||||
@@ -3135,53 +3056,6 @@ func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error)
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseIsHealthyResponse parses an HTTP response from a IsHealthyWithResponse call
|
|
||||||
func ParseIsHealthyResponse(rsp *http.Response) (*IsHealthyResponse, error) {
|
|
||||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
||||||
defer func() { _ = rsp.Body.Close() }()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response := &IsHealthyResponse{
|
|
||||||
Body: bodyBytes,
|
|
||||||
HTTPResponse: rsp,
|
|
||||||
}
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
|
|
||||||
var dest InvalidRequest
|
|
||||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
response.JSON400 = &dest
|
|
||||||
|
|
||||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401:
|
|
||||||
var dest Unauthorized
|
|
||||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
response.JSON401 = &dest
|
|
||||||
|
|
||||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429:
|
|
||||||
var dest TooManyRequests
|
|
||||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
response.JSON429 = &dest
|
|
||||||
|
|
||||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500:
|
|
||||||
var dest InternalError
|
|
||||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
response.JSON500 = &dest
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseGetHomePageResponse parses an HTTP response from a GetHomePageWithResponse call
|
// ParseGetHomePageResponse parses an HTTP response from a GetHomePageWithResponse call
|
||||||
func ParseGetHomePageResponse(rsp *http.Response) (*GetHomePageResponse, error) {
|
func ParseGetHomePageResponse(rsp *http.Response) (*GetHomePageResponse, error) {
|
||||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||||
|
|||||||
@@ -27,33 +27,8 @@ tags:
|
|||||||
description: Operations related to exports
|
description: Operations related to exports
|
||||||
- name: AuthService
|
- name: AuthService
|
||||||
description: Operations related to authentication
|
description: Operations related to authentication
|
||||||
- name: HealthService
|
|
||||||
description: Operations related to health
|
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/health:
|
|
||||||
get:
|
|
||||||
operationId: isHealthy
|
|
||||||
tags:
|
|
||||||
- HealthService
|
|
||||||
summary: Provide health endpoint
|
|
||||||
description: See if the service is up and running
|
|
||||||
security:
|
|
||||||
- {}
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Healthy service.
|
|
||||||
headers:
|
|
||||||
RateLimit:
|
|
||||||
$ref: "#/components/headers/RateLimit"
|
|
||||||
"400":
|
|
||||||
$ref: "#/components/responses/InvalidRequest"
|
|
||||||
"401":
|
|
||||||
$ref: "#/components/responses/Unauthorized"
|
|
||||||
"429":
|
|
||||||
$ref: "#/components/responses/TooManyRequests"
|
|
||||||
"500":
|
|
||||||
$ref: "#/components/responses/InternalError"
|
|
||||||
|
|
||||||
/client:
|
/client:
|
||||||
post:
|
post:
|
||||||
|
|||||||
Reference in New Issue
Block a user