oas

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL added in v0.2.0

func WithServerURL(ctx context.Context, u *url.URL) context.Context

WithServerURL sets context key to override server URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements OAS client.

func NewClient

func NewClient(serverURL string, opts ...ClientOption) (*Client, error)

NewClient initializes new Client defined by OAS.

func (*Client) Poll

func (c *Client) Poll(ctx context.Context, params PollParams) (Job, error)

Poll invokes poll operation.

Request job from coordinator.

POST /job/poll

func (*Client) Progress

func (c *Client) Progress(ctx context.Context, request *Progress, params ProgressParams) (*Status, error)

Progress invokes progress operation.

Report progress.

POST /progress

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*Status, error)

Status invokes status operation.

Get status.

GET /status

type ClientOption added in v0.2.0

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption is client config option.

func WithClient

func WithClient(client ht.Client) ClientOption

WithClient specifies http client to use.

type Error

type Error struct {
	Message string `json:"message"`
}

Error description. Ref: #/components/schemas/Error

func (*Error) Decode

func (s *Error) Decode(d *jx.Decoder) error

Decode decodes Error from json.

func (*Error) Encode

func (s *Error) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Error) GetMessage added in v0.2.0

func (s *Error) GetMessage() string

GetMessage returns the value of Message.

func (*Error) MarshalJSON added in v0.2.0

func (s *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Error) SetMessage added in v0.2.0

func (s *Error) SetMessage(val string)

SetMessage sets the value of Message.

func (*Error) UnmarshalJSON added in v0.2.0

func (s *Error) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type ErrorHandler added in v0.2.0

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type ErrorStatusCode

type ErrorStatusCode struct {
	StatusCode int
	Response   Error
}

ErrorStatusCode wraps Error with StatusCode.

func (*ErrorStatusCode) Error

func (s *ErrorStatusCode) Error() string

func (*ErrorStatusCode) GetResponse added in v0.2.0

func (s *ErrorStatusCode) GetResponse() Error

GetResponse returns the value of Response.

func (*ErrorStatusCode) GetStatusCode added in v0.2.0

func (s *ErrorStatusCode) GetStatusCode() int

GetStatusCode returns the value of StatusCode.

func (*ErrorStatusCode) SetResponse added in v0.2.0

func (s *ErrorStatusCode) SetResponse(val Error)

SetResponse sets the value of Response.

func (*ErrorStatusCode) SetStatusCode added in v0.2.0

func (s *ErrorStatusCode) SetStatusCode(val int)

SetStatusCode sets the value of StatusCode.

type Handler

type Handler interface {
	// Poll implements poll operation.
	//
	// Request job from coordinator.
	//
	// POST /job/poll
	Poll(ctx context.Context, params PollParams) (Job, error)
	// Progress implements progress operation.
	//
	// Report progress.
	//
	// POST /progress
	Progress(ctx context.Context, req *Progress, params ProgressParams) (*Status, error)
	// Status implements status operation.
	//
	// Get status.
	//
	// GET /status
	Status(ctx context.Context) (*Status, error)
	// NewError creates *ErrorStatusCode from error returned by handler.
	//
	// Used for common default response.
	NewError(ctx context.Context, err error) *ErrorStatusCode
}

Handler handles operations described by OpenAPI v3 specification.

type Job

type Job struct {
	Type        JobType // switch on this field
	JobNothing  JobNothing
	JobDownload JobDownload
	JobProcess  JobProcess
}

Job to perform on worker. Ref: #/components/schemas/Job Job represents sum type.

func NewJobDownloadJob

func NewJobDownloadJob(v JobDownload) Job

NewJobDownloadJob returns new Job from JobDownload.

func NewJobNothingJob

func NewJobNothingJob(v JobNothing) Job

NewJobNothingJob returns new Job from JobNothing.

func NewJobProcessJob added in v0.2.0

func NewJobProcessJob(v JobProcess) Job

NewJobProcessJob returns new Job from JobProcess.

func (*Job) Decode

func (s *Job) Decode(d *jx.Decoder) error

Decode decodes Job from json.

func (Job) Encode

func (s Job) Encode(e *jx.Encoder)

Encode encodes Job as json.

func (Job) GetJobDownload

func (s Job) GetJobDownload() (v JobDownload, ok bool)

GetJobDownload returns JobDownload and true boolean if Job is JobDownload.

func (Job) GetJobNothing

func (s Job) GetJobNothing() (v JobNothing, ok bool)

GetJobNothing returns JobNothing and true boolean if Job is JobNothing.

func (Job) GetJobProcess added in v0.2.0

func (s Job) GetJobProcess() (v JobProcess, ok bool)

GetJobProcess returns JobProcess and true boolean if Job is JobProcess.

func (Job) IsJobDownload

func (s Job) IsJobDownload() bool

IsJobDownload reports whether Job is JobDownload.

func (Job) IsJobNothing

func (s Job) IsJobNothing() bool

IsJobNothing reports whether Job is JobNothing.

func (Job) IsJobProcess added in v0.2.0

func (s Job) IsJobProcess() bool

IsJobProcess reports whether Job is JobProcess.

func (Job) MarshalJSON added in v0.2.0

func (s Job) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Job) SetJobDownload

func (s *Job) SetJobDownload(v JobDownload)

SetJobDownload sets Job to JobDownload.

func (*Job) SetJobNothing

func (s *Job) SetJobNothing(v JobNothing)

SetJobNothing sets Job to JobNothing.

func (*Job) SetJobProcess added in v0.2.0

func (s *Job) SetJobProcess(v JobProcess)

SetJobProcess sets Job to JobProcess.

func (*Job) UnmarshalJSON added in v0.2.0

func (s *Job) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (Job) Validate

func (s Job) Validate() error

type JobDownload

type JobDownload struct {
	Date string `json:"date"`
}

Download chunk. Ref: #/components/schemas/JobDownload

func (*JobDownload) Decode

func (s *JobDownload) Decode(d *jx.Decoder) error

Decode decodes JobDownload from json.

func (*JobDownload) Encode

func (s *JobDownload) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*JobDownload) GetDate added in v0.2.0

func (s *JobDownload) GetDate() string

GetDate returns the value of Date.

func (*JobDownload) MarshalJSON added in v0.2.0

func (s *JobDownload) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*JobDownload) SetDate added in v0.2.0

func (s *JobDownload) SetDate(val string)

SetDate sets the value of Date.

func (*JobDownload) UnmarshalJSON added in v0.2.0

func (s *JobDownload) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type JobNothing

type JobNothing struct{}

Do nothing. Ref: #/components/schemas/JobNothing

func (*JobNothing) Decode

func (s *JobNothing) Decode(d *jx.Decoder) error

Decode decodes JobNothing from json.

func (*JobNothing) Encode

func (s *JobNothing) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*JobNothing) MarshalJSON added in v0.2.0

func (s *JobNothing) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*JobNothing) UnmarshalJSON added in v0.2.0

func (s *JobNothing) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type JobProcess added in v0.2.0

type JobProcess struct {
	Keys       []string `json:"keys"`
	Clickhouse string   `json:"clickhouse"`
}

Process job. Ref: #/components/schemas/JobProcess

func (*JobProcess) Decode added in v0.2.0

func (s *JobProcess) Decode(d *jx.Decoder) error

Decode decodes JobProcess from json.

func (*JobProcess) Encode added in v0.2.0

func (s *JobProcess) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*JobProcess) GetClickhouse added in v0.2.0

func (s *JobProcess) GetClickhouse() string

GetClickhouse returns the value of Clickhouse.

func (*JobProcess) GetKeys added in v0.2.0

func (s *JobProcess) GetKeys() []string

GetKeys returns the value of Keys.

func (*JobProcess) MarshalJSON added in v0.2.0

func (s *JobProcess) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*JobProcess) SetClickhouse added in v0.2.0

func (s *JobProcess) SetClickhouse(val string)

SetClickhouse sets the value of Clickhouse.

func (*JobProcess) SetKeys added in v0.2.0

func (s *JobProcess) SetKeys(val []string)

SetKeys sets the value of Keys.

func (*JobProcess) UnmarshalJSON added in v0.2.0

func (s *JobProcess) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*JobProcess) Validate added in v0.2.0

func (s *JobProcess) Validate() error

type JobType

type JobType string

JobType is oneOf type of Job.

const (
	JobNothingJob  JobType = "JobNothing"
	JobDownloadJob JobType = "JobDownload"
	JobProcessJob  JobType = "JobProcess"
)

Possible values for JobType.

type Middleware added in v0.2.0

type Middleware = middleware.Middleware

Middleware is middleware type.

type OptInt64

type OptInt64 struct {
	Value int64
	Set   bool
}

OptInt64 is optional int64.

func NewOptInt64

func NewOptInt64(v int64) OptInt64

NewOptInt64 returns new OptInt64 with value set to v.

func (*OptInt64) Decode

func (o *OptInt64) Decode(d *jx.Decoder) error

Decode decodes int64 from json.

func (OptInt64) Encode

func (o OptInt64) Encode(e *jx.Encoder)

Encode encodes int64 as json.

func (OptInt64) Get

func (o OptInt64) Get() (v int64, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptInt64) IsSet

func (o OptInt64) IsSet() bool

IsSet returns true if OptInt64 was set.

func (OptInt64) MarshalJSON added in v0.2.0

func (s OptInt64) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptInt64) Or added in v0.2.0

func (o OptInt64) Or(d int64) int64

Or returns value if set, or given parameter if does not.

func (*OptInt64) Reset

func (o *OptInt64) Reset()

Reset unsets value.

func (*OptInt64) SetTo

func (o *OptInt64) SetTo(v int64)

SetTo sets value to v.

func (*OptInt64) UnmarshalJSON added in v0.2.0

func (s *OptInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type OptString

type OptString struct {
	Value string
	Set   bool
}

OptString is optional string.

func NewOptString

func NewOptString(v string) OptString

NewOptString returns new OptString with value set to v.

func (*OptString) Decode

func (o *OptString) Decode(d *jx.Decoder) error

Decode decodes string from json.

func (OptString) Encode

func (o OptString) Encode(e *jx.Encoder)

Encode encodes string as json.

func (OptString) Get

func (o OptString) Get() (v string, ok bool)

Get returns value and boolean that denotes whether value was set.

func (OptString) IsSet

func (o OptString) IsSet() bool

IsSet returns true if OptString was set.

func (OptString) MarshalJSON added in v0.2.0

func (s OptString) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (OptString) Or added in v0.2.0

func (o OptString) Or(d string) string

Or returns value if set, or given parameter if does not.

func (*OptString) Reset

func (o *OptString) Reset()

Reset unsets value.

func (*OptString) SetTo

func (o *OptString) SetTo(v string)

SetTo sets value to v.

func (*OptString) UnmarshalJSON added in v0.2.0

func (s *OptString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithMeterProvider added in v0.2.0

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter.

If none is specified, the otel.GetMeterProvider() is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer.

If none is specified, the global provider is used.

type PollParams

type PollParams struct {
	// Worker token.
	XToken string
}

PollParams is parameters of poll operation.

type Progress

type Progress struct {
	Event ProgressEvent `json:"event"`
	// Chunk key.
	Key              string    `json:"key"`
	InputSizeBytes   OptInt64  `json:"input_size_bytes"`
	ContentSizeBytes OptInt64  `json:"content_size_bytes"`
	OutputSizeBytes  OptInt64  `json:"output_size_bytes"`
	InputReadyBytes  OptInt64  `json:"input_ready_bytes"`
	SHA256Input      OptString `json:"sha256_input"`
	SHA256Content    OptString `json:"sha256_content"`
	SHA256Output     OptString `json:"sha256_output"`
}

Ref: #/components/schemas/Progress

func (*Progress) Decode

func (s *Progress) Decode(d *jx.Decoder) error

Decode decodes Progress from json.

func (*Progress) Encode

func (s *Progress) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Progress) GetContentSizeBytes added in v0.2.0

func (s *Progress) GetContentSizeBytes() OptInt64

GetContentSizeBytes returns the value of ContentSizeBytes.

func (*Progress) GetEvent added in v0.2.0

func (s *Progress) GetEvent() ProgressEvent

GetEvent returns the value of Event.

func (*Progress) GetInputReadyBytes added in v0.2.0

func (s *Progress) GetInputReadyBytes() OptInt64

GetInputReadyBytes returns the value of InputReadyBytes.

func (*Progress) GetInputSizeBytes added in v0.2.0

func (s *Progress) GetInputSizeBytes() OptInt64

GetInputSizeBytes returns the value of InputSizeBytes.

func (*Progress) GetKey added in v0.2.0

func (s *Progress) GetKey() string

GetKey returns the value of Key.

func (*Progress) GetOutputSizeBytes added in v0.2.0

func (s *Progress) GetOutputSizeBytes() OptInt64

GetOutputSizeBytes returns the value of OutputSizeBytes.

func (*Progress) GetSHA256Content added in v0.2.0

func (s *Progress) GetSHA256Content() OptString

GetSHA256Content returns the value of SHA256Content.

func (*Progress) GetSHA256Input added in v0.2.0

func (s *Progress) GetSHA256Input() OptString

GetSHA256Input returns the value of SHA256Input.

func (*Progress) GetSHA256Output added in v0.2.0

func (s *Progress) GetSHA256Output() OptString

GetSHA256Output returns the value of SHA256Output.

func (*Progress) MarshalJSON added in v0.2.0

func (s *Progress) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Progress) SetContentSizeBytes added in v0.2.0

func (s *Progress) SetContentSizeBytes(val OptInt64)

SetContentSizeBytes sets the value of ContentSizeBytes.

func (*Progress) SetEvent added in v0.2.0

func (s *Progress) SetEvent(val ProgressEvent)

SetEvent sets the value of Event.

func (*Progress) SetInputReadyBytes added in v0.2.0

func (s *Progress) SetInputReadyBytes(val OptInt64)

SetInputReadyBytes sets the value of InputReadyBytes.

func (*Progress) SetInputSizeBytes added in v0.2.0

func (s *Progress) SetInputSizeBytes(val OptInt64)

SetInputSizeBytes sets the value of InputSizeBytes.

func (*Progress) SetKey added in v0.2.0

func (s *Progress) SetKey(val string)

SetKey sets the value of Key.

func (*Progress) SetOutputSizeBytes added in v0.2.0

func (s *Progress) SetOutputSizeBytes(val OptInt64)

SetOutputSizeBytes sets the value of OutputSizeBytes.

func (*Progress) SetSHA256Content added in v0.2.0

func (s *Progress) SetSHA256Content(val OptString)

SetSHA256Content sets the value of SHA256Content.

func (*Progress) SetSHA256Input added in v0.2.0

func (s *Progress) SetSHA256Input(val OptString)

SetSHA256Input sets the value of SHA256Input.

func (*Progress) SetSHA256Output added in v0.2.0

func (s *Progress) SetSHA256Output(val OptString)

SetSHA256Output sets the value of SHA256Output.

func (*Progress) UnmarshalJSON added in v0.2.0

func (s *Progress) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*Progress) Validate

func (s *Progress) Validate() error

type ProgressEvent

type ProgressEvent string
const (
	ProgressEventReady       ProgressEvent = "Ready"
	ProgressEventDownloading ProgressEvent = "Downloading"
	ProgressEventProcessed   ProgressEvent = "Processed"
)

func (*ProgressEvent) Decode

func (s *ProgressEvent) Decode(d *jx.Decoder) error

Decode decodes ProgressEvent from json.

func (ProgressEvent) Encode

func (s ProgressEvent) Encode(e *jx.Encoder)

Encode encodes ProgressEvent as json.

func (ProgressEvent) MarshalJSON added in v0.2.0

func (s ProgressEvent) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (ProgressEvent) MarshalText added in v0.2.0

func (s ProgressEvent) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*ProgressEvent) UnmarshalJSON added in v0.2.0

func (s *ProgressEvent) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

func (*ProgressEvent) UnmarshalText added in v0.2.0

func (s *ProgressEvent) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ProgressEvent) Validate

func (s ProgressEvent) Validate() error

type ProgressParams

type ProgressParams struct {
	// Worker token.
	XToken string
}

ProgressParams is parameters of progress operation.

type Route added in v0.2.0

type Route struct {
	// contains filtered or unexported fields
}

Route is route object.

func (Route) Args added in v0.2.0

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name added in v0.2.0

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationID added in v0.2.0

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern added in v0.2.0

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements http server based on OpenAPI v3 specification and calls Handler to handle requests.

func NewServer

func NewServer(h Handler, opts ...ServerOption) (*Server, error)

NewServer creates new Server.

func (*Server) FindPath added in v0.2.0

func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool)

FindPath finds Route for given method and URL.

func (*Server) FindRoute added in v0.2.0

func (s *Server) FindRoute(method, path string) (Route, bool)

FindRoute finds Route for given method and path.

Note: this method does not unescape path or handle reserved characters in path properly. Use FindPath instead.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves http request as defined by OpenAPI v3 specification, calling handler that matches the path or returning not found error.

type ServerOption added in v0.2.0

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption is server config option.

func WithErrorHandler added in v0.2.0

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory added in v0.2.0

func WithMaxMultipartMemory(max int64) ServerOption

WithMaxMultipartMemory specifies limit of memory for storing file parts. File parts which can't be stored in memory will be stored on disk in temporary files.

func WithMethodNotAllowed added in v0.2.0

func WithMethodNotAllowed(methodNotAllowed func(w http.ResponseWriter, r *http.Request, allowed string)) ServerOption

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware added in v0.2.0

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound added in v0.2.0

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix added in v0.2.0

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type Status

type Status struct {
	Message string `json:"message"`
}

Ref: #/components/schemas/Status

func (*Status) Decode

func (s *Status) Decode(d *jx.Decoder) error

Decode decodes Status from json.

func (*Status) Encode

func (s *Status) Encode(e *jx.Encoder)

Encode implements json.Marshaler.

func (*Status) GetMessage added in v0.2.0

func (s *Status) GetMessage() string

GetMessage returns the value of Message.

func (*Status) MarshalJSON added in v0.2.0

func (s *Status) MarshalJSON() ([]byte, error)

MarshalJSON implements stdjson.Marshaler.

func (*Status) SetMessage added in v0.2.0

func (s *Status) SetMessage(val string)

SetMessage sets the value of Message.

func (*Status) UnmarshalJSON added in v0.2.0

func (s *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON implements stdjson.Unmarshaler.

type UnimplementedHandler added in v0.2.0

type UnimplementedHandler struct{}

UnimplementedHandler is no-op Handler which returns http.ErrNotImplemented.

func (UnimplementedHandler) NewError added in v0.2.0

func (UnimplementedHandler) NewError(ctx context.Context, err error) (r *ErrorStatusCode)

NewError creates *ErrorStatusCode from error returned by handler.

Used for common default response.

func (UnimplementedHandler) Poll added in v0.2.0

func (UnimplementedHandler) Poll(ctx context.Context, params PollParams) (r Job, _ error)

Poll implements poll operation.

Request job from coordinator.

POST /job/poll

func (UnimplementedHandler) Progress added in v0.2.0

func (UnimplementedHandler) Progress(ctx context.Context, req *Progress, params ProgressParams) (r *Status, _ error)

Progress implements progress operation.

Report progress.

POST /progress

func (UnimplementedHandler) Status added in v0.2.0

func (UnimplementedHandler) Status(ctx context.Context) (r *Status, _ error)

Status implements status operation.

Get status.

GET /status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL