techempower

package
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL added in v0.50.0

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

WithServerURL sets context key to override server URL.

Types

type CachingParams

type CachingParams struct {
	Count int64
}

type Client

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

Client implements OAS client.

func NewClient

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

NewClient initializes new Client defined by OAS.

func (*Client) Caching

func (c *Client) Caching(ctx context.Context, params CachingParams) (res WorldObjects, err error)

Caching invokes Caching operation.

Test #7. The Caching test exercises the preferred in-memory or separate-process caching technology for the platform or framework. For implementation simplicity, the requirements are very similar to the multiple database-query test Test #3, but use a separate database table. The requirements are quite generous, affording each framework fairly broad freedom to meet the requirements in the manner that best represents the canonical non-distributed caching approach for the framework. (Note: a distributed caching test type could be added later.).

GET /cached-worlds

func (*Client) DB

func (c *Client) DB(ctx context.Context) (res WorldObject, err error)

DB invokes DB operation.

Test #2. The Single Database Query test exercises the framework's object-relational mapper (ORM), random number generator, database driver, and database connection pool.

GET /db

func (*Client) JSON

func (c *Client) JSON(ctx context.Context) (res HelloWorld, err error)

JSON invokes json operation.

Test #1. The JSON Serialization test exercises the framework fundamentals including keep-alive support, request routing, request header parsing, object instantiation, JSON serialization, response header generation, and request count throughput.

GET /json

func (*Client) Queries

func (c *Client) Queries(ctx context.Context, params QueriesParams) (res WorldObjects, err error)

Queries invokes Queries operation.

Test #3. The Multiple Database Queries test is a variation of Test #2 and also uses the World table. Multiple rows are fetched to more dramatically punish the database driver and connection pool. At the highest queries-per-request tested (20), this test demonstrates all frameworks' convergence toward zero requests-per-second as database activity increases.

GET /queries

func (*Client) Updates

func (c *Client) Updates(ctx context.Context, params UpdatesParams) (res WorldObjects, err error)

Updates invokes Updates operation.

Test #5. The Database Updates test is a variation of Test #3 that exercises the ORM's persistence of objects and the database driver's performance at running UPDATE statements or similar. The spirit of this test is to exercise a variable number of read-then-write style database operations.

GET /updates

type ErrorHandler added in v0.25.0

type ErrorHandler = ogenerrors.ErrorHandler

ErrorHandler is error handler.

type Handler

type Handler interface {
	// Caching implements Caching operation.
	//
	// Test #7. The Caching test exercises the preferred in-memory or separate-process caching technology
	// for the platform or framework. For implementation simplicity, the requirements are very similar to
	// the multiple database-query test Test #3, but use a separate database table. The requirements are
	// quite generous, affording each framework fairly broad freedom to meet the requirements in the
	// manner that best represents the canonical non-distributed caching approach for the framework.
	// (Note: a distributed caching test type could be added later.).
	//
	// GET /cached-worlds
	Caching(ctx context.Context, params CachingParams) (WorldObjects, error)
	// DB implements DB operation.
	//
	// Test #2. The Single Database Query test exercises the framework's object-relational mapper (ORM),
	// random number generator, database driver, and database connection pool.
	//
	// GET /db
	DB(ctx context.Context) (WorldObject, error)
	// JSON implements json operation.
	//
	// Test #1. The JSON Serialization test exercises the framework fundamentals including keep-alive
	// support, request routing, request header parsing, object instantiation, JSON serialization,
	// response header generation, and request count throughput.
	//
	// GET /json
	JSON(ctx context.Context) (HelloWorld, error)
	// Queries implements Queries operation.
	//
	// Test #3. The Multiple Database Queries test is a variation of Test #2 and also uses the World
	// table. Multiple rows are fetched to more dramatically punish the database driver and connection
	// pool. At the highest queries-per-request tested (20), this test demonstrates all frameworks'
	// convergence toward zero requests-per-second as database activity increases.
	//
	// GET /queries
	Queries(ctx context.Context, params QueriesParams) (WorldObjects, error)
	// Updates implements Updates operation.
	//
	// Test #5. The Database Updates test is a variation of Test #3 that exercises the ORM's persistence
	// of objects and the database driver's performance at running UPDATE statements or similar. The
	// spirit of this test is to exercise a variable number of read-then-write style database operations.
	//
	// GET /updates
	Updates(ctx context.Context, params UpdatesParams) (WorldObjects, error)
}

Handler handles operations described by OpenAPI v3 specification.

type HelloWorld

type HelloWorld struct {
	// Should be equal to 'Hello, World!'.
	Message string `json:"message"`
}

Ref: #/components/schemas/HelloWorld

func (*HelloWorld) Decode

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

Decode decodes HelloWorld from json.

func (HelloWorld) Encode

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

Encode implements json.Marshaler.

func (HelloWorld) GetMessage added in v0.52.0

func (s HelloWorld) GetMessage() string

GetMessage returns the value of Message.

func (HelloWorld) MarshalJSON added in v0.20.0

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

MarshalJSON implements stdjson.Marshaler.

func (*HelloWorld) SetFake added in v0.19.0

func (s *HelloWorld) SetFake()

SetFake set fake values.

func (*HelloWorld) SetMessage added in v0.52.0

func (s *HelloWorld) SetMessage(val string)

SetMessage sets the value of Message.

func (*HelloWorld) UnmarshalJSON added in v0.20.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Middleware added in v0.49.0

type Middleware = middleware.Middleware

Middleware is middleware type.

type Option

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

func WithClient

func WithClient(client ht.Client) Option

WithClient specifies http client to use.

func WithErrorHandler added in v0.25.0

func WithErrorHandler(h ErrorHandler) Option

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory added in v0.34.0

func WithMaxMultipartMemory(max int64) Option

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 WithMeterProvider added in v0.13.0

func WithMeterProvider(provider metric.MeterProvider) Option

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

If none is specified, the metric.NewNoopMeterProvider is used.

func WithMethodNotAllowed added in v0.46.0

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

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware added in v0.49.0

func WithMiddleware(m ...Middleware) Option

WithMiddleware specifies middlewares to use.

func WithNotFound added in v0.18.0

func WithNotFound(notFound http.HandlerFunc) Option

WithNotFound specifies Not Found handler to use.

func WithPathPrefix added in v0.52.0

func WithPathPrefix(prefix string) Option

WithPathPrefix specifies server path prefix.

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 QueriesParams

type QueriesParams struct {
	Queries int64
}

type Route added in v0.8.0

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

Route is route object.

func (Route) Args added in v0.8.0

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name added in v0.46.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.8.0

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

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 ...Option) (*Server, error)

NewServer creates new Server.

func (*Server) FindRoute added in v0.8.0

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

FindRoute finds Route for given method and path.

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 UnimplementedHandler added in v0.18.0

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) Caching added in v0.18.0

Caching implements Caching operation.

Test #7. The Caching test exercises the preferred in-memory or separate-process caching technology for the platform or framework. For implementation simplicity, the requirements are very similar to the multiple database-query test Test #3, but use a separate database table. The requirements are quite generous, affording each framework fairly broad freedom to meet the requirements in the manner that best represents the canonical non-distributed caching approach for the framework. (Note: a distributed caching test type could be added later.).

GET /cached-worlds

func (UnimplementedHandler) DB added in v0.18.0

DB implements DB operation.

Test #2. The Single Database Query test exercises the framework's object-relational mapper (ORM), random number generator, database driver, and database connection pool.

GET /db

func (UnimplementedHandler) JSON added in v0.18.0

JSON implements json operation.

Test #1. The JSON Serialization test exercises the framework fundamentals including keep-alive support, request routing, request header parsing, object instantiation, JSON serialization, response header generation, and request count throughput.

GET /json

func (UnimplementedHandler) Queries added in v0.18.0

Queries implements Queries operation.

Test #3. The Multiple Database Queries test is a variation of Test #2 and also uses the World table. Multiple rows are fetched to more dramatically punish the database driver and connection pool. At the highest queries-per-request tested (20), this test demonstrates all frameworks' convergence toward zero requests-per-second as database activity increases.

GET /queries

func (UnimplementedHandler) Updates added in v0.18.0

Updates implements Updates operation.

Test #5. The Database Updates test is a variation of Test #3 that exercises the ORM's persistence of objects and the database driver's performance at running UPDATE statements or similar. The spirit of this test is to exercise a variable number of read-then-write style database operations.

GET /updates

type UpdatesParams

type UpdatesParams struct {
	Queries int64
}

type WorldObject

type WorldObject struct {
	ID           int64 `json:"id"`
	RandomNumber int64 `json:"randomNumber"`
}

Ref: #/components/schemas/WorldObject

func (*WorldObject) Decode

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

Decode decodes WorldObject from json.

func (WorldObject) Encode

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

Encode implements json.Marshaler.

func (WorldObject) GetID added in v0.52.0

func (s WorldObject) GetID() int64

GetID returns the value of ID.

func (WorldObject) GetRandomNumber added in v0.52.0

func (s WorldObject) GetRandomNumber() int64

GetRandomNumber returns the value of RandomNumber.

func (WorldObject) MarshalJSON added in v0.20.0

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

MarshalJSON implements stdjson.Marshaler.

func (*WorldObject) SetFake added in v0.19.0

func (s *WorldObject) SetFake()

SetFake set fake values.

func (*WorldObject) SetID added in v0.52.0

func (s *WorldObject) SetID(val int64)

SetID sets the value of ID.

func (*WorldObject) SetRandomNumber added in v0.52.0

func (s *WorldObject) SetRandomNumber(val int64)

SetRandomNumber sets the value of RandomNumber.

func (*WorldObject) UnmarshalJSON added in v0.20.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

type WorldObjects

type WorldObjects []WorldObject

func (*WorldObjects) Decode

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

Decode decodes WorldObjects from json.

func (WorldObjects) Encode

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

Encode encodes WorldObjects as json.

func (WorldObjects) MarshalJSON added in v0.20.0

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

MarshalJSON implements stdjson.Marshaler.

func (*WorldObjects) SetFake added in v0.19.0

func (s *WorldObjects) SetFake()

SetFake set fake values.

func (*WorldObjects) UnmarshalJSON added in v0.20.0

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

UnmarshalJSON implements stdjson.Unmarshaler.

func (WorldObjects) Validate

func (s WorldObjects) Validate() error

Jump to

Keyboard shortcuts

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