techempower

package
v0.0.0-...-5415eb5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServerURL

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
}

CachingParams is parameters of Caching operation.

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) Caching

func (c *Client) Caching(ctx context.Context, params CachingParams) (WorldObjects, 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) (*WorldObject, 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) (*HelloWorld, 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) (WorldObjects, 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) (WorldObjects, 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 ClientOption

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 ErrorHandler

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

func (s *HelloWorld) GetMessage() string

GetMessage returns the value of Message.

func (*HelloWorld) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*HelloWorld) SetFake

func (s *HelloWorld) SetFake()

SetFake set fake values.

func (*HelloWorld) SetMessage

func (s *HelloWorld) SetMessage(val string)

SetMessage sets the value of Message.

func (*HelloWorld) UnmarshalJSON

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

UnmarshalJSON implements stdjson.Unmarshaler.

type Invoker

type Invoker interface {
	// 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
	Caching(ctx context.Context, params CachingParams) (WorldObjects, 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
	DB(ctx context.Context) (*WorldObject, 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
	JSON(ctx context.Context) (*HelloWorld, 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
	Queries(ctx context.Context, params QueriesParams) (WorldObjects, 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
	Updates(ctx context.Context, params UpdatesParams) (WorldObjects, error)
}

Invoker invokes operations described by OpenAPI v3 specification.

type Labeler

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

Labeler is used to allow adding custom attributes to the server request metrics.

func LabelerFromContext

func LabelerFromContext(ctx context.Context) (*Labeler, bool)

LabelerFromContext retrieves the Labeler from the provided context, if present.

If no Labeler was found in the provided context a new, empty Labeler is returned and the second return value is false. In this case it is safe to use the Labeler but any attributes added to it will not be used.

func (*Labeler) Add

func (l *Labeler) Add(attrs ...attribute.KeyValue)

Add attributes to the Labeler.

func (*Labeler) AttributeSet

func (l *Labeler) AttributeSet() attribute.Set

AttributeSet returns the attributes added to the Labeler as an attribute.Set.

type Middleware

type Middleware = middleware.Middleware

Middleware is middleware type.

type Option

type Option interface {
	ServerOption
	ClientOption
}

Option is config option.

func WithMeterProvider

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 QueriesParams

type QueriesParams struct {
	Queries int64
}

QueriesParams is parameters of Queries operation.

type Route

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

Route is route object.

func (Route) Args

func (r Route) Args() []string

Args returns parsed arguments.

func (Route) Name

func (r Route) Name() string

Name returns ogen operation name.

It is guaranteed to be unique and not empty.

func (Route) OperationID

func (r Route) OperationID() string

OperationID returns OpenAPI operationId.

func (Route) PathPattern

func (r Route) PathPattern() string

PathPattern returns OpenAPI path.

func (Route) Summary

func (r Route) Summary() string

Summary returns OpenAPI summary.

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

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

FindPath finds Route for given method and URL.

func (*Server) FindRoute

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

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

ServerOption is server config option.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ServerOption

WithErrorHandler specifies error handler to use.

func WithMaxMultipartMemory

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

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

WithMethodNotAllowed specifies Method Not Allowed handler to use.

func WithMiddleware

func WithMiddleware(m ...Middleware) ServerOption

WithMiddleware specifies middlewares to use.

func WithNotFound

func WithNotFound(notFound http.HandlerFunc) ServerOption

WithNotFound specifies Not Found handler to use.

func WithPathPrefix

func WithPathPrefix(prefix string) ServerOption

WithPathPrefix specifies server path prefix.

type UnimplementedHandler

type UnimplementedHandler struct{}

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

func (UnimplementedHandler) Caching

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

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

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

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

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
}

UpdatesParams is parameters of Updates operation.

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

func (s *WorldObject) GetID() int64

GetID returns the value of ID.

func (*WorldObject) GetRandomNumber

func (s *WorldObject) GetRandomNumber() int64

GetRandomNumber returns the value of RandomNumber.

func (*WorldObject) MarshalJSON

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

MarshalJSON implements stdjson.Marshaler.

func (*WorldObject) SetFake

func (s *WorldObject) SetFake()

SetFake set fake values.

func (*WorldObject) SetID

func (s *WorldObject) SetID(val int64)

SetID sets the value of ID.

func (*WorldObject) SetRandomNumber

func (s *WorldObject) SetRandomNumber(val int64)

SetRandomNumber sets the value of RandomNumber.

func (*WorldObject) UnmarshalJSON

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

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

MarshalJSON implements stdjson.Marshaler.

func (*WorldObjects) SetFake

func (s *WorldObjects) SetFake()

SetFake set fake values.

func (*WorldObjects) UnmarshalJSON

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