lava

package
v0.2.10-8 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCtxWithReqHeader

func CreateCtxWithReqHeader(ctx context.Context, header *RequestHeader) context.Context

func CreateCtxWithReqID

func CreateCtxWithReqID(ctx context.Context, reqId string) context.Context

func CreateCtxWithRspHeader

func CreateCtxWithRspHeader(ctx context.Context, header *ResponseHeader) context.Context

func GetReqID

func GetReqID(ctx context.Context) string

func WrapHandler

func WrapHandler[Req any, Rsp any](handle func(ctx context.Context, req *Req) (rsp *Rsp, err error)) func(ctx *fiber.Ctx) error

Types

type Close

type Close interface {
	Close()
}

type GrpcHandler

type GrpcHandler interface {
	Init()
	Middlewares() []Middleware
	ServiceDesc() *grpc.ServiceDesc
	Gateway(opts []interface{}) TwirpServer
}

type HandlerFunc

type HandlerFunc func(ctx context.Context, req Request) (Response, error)

type HttpRouter

type HttpRouter interface {
	Init()
	Middlewares() []Middleware
	Router(app *fiber.App)
	Openapi(swag *opendoc.Swagger)
}

type Init

type Init interface {
	Init()
}

type Middleware

type Middleware func(next HandlerFunc) HandlerFunc

func Chain

func Chain(m ...Middleware) Middleware

type Request

type Request interface {
	// Client server or client
	Client() bool

	// Kind [http|grpc...]
	Kind() string

	// Stream Indicates whether it's a stream
	Stream() bool

	// Service name requested
	Service() string

	// Operation requested
	Operation() string

	// Endpoint requested
	Endpoint() string

	// ContentType Content type provided
	ContentType() string

	// Header of the request
	Header() *RequestHeader

	// Payload is the decoded value
	Payload() interface{}
}

Request is a synchronous request interface

type RequestHeader

type RequestHeader = fasthttp.RequestHeader

func GetReqHeader

func GetReqHeader(ctx context.Context) *RequestHeader

type Response

type Response interface {
	Header() *ResponseHeader
	Payload() interface{}
	Stream() bool
}

Response is the response writer for un encoded messages

type ResponseHeader

type ResponseHeader = fasthttp.ResponseHeader

func GetRspHeader

func GetRspHeader(ctx context.Context) *ResponseHeader

type Service

type Service interface {
	Start()
	Stop()
	Run()
}

type TwirpServer

type TwirpServer interface {
	http.Handler

	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)

	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string

	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route Twirp requests.
	// The path prefix is in the form: "/<prefix>/<package>.<Service>/"
	// that is, everything in a Twirp route except for the <Method> at the end.
	PathPrefix() string
}

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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