endpoint

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 2 Imported by: 0

README

design pattern

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyEndpoint added in v1.2.6

type AnyEndpoint Endpoint[any, any]

type AnyEndpointFunc added in v1.2.6

type AnyEndpointFunc Func[any, any]

type Decorator added in v1.3.2

type Decorator[Req any, Resp any] decorator.Decorator[Endpoint[Req, Resp]]

type DecoratorFunc added in v1.3.2

type DecoratorFunc[Req any, Resp any] decorator.Func[Endpoint[Req, Resp]]

type Endpoint

type Endpoint[Req any, Resp any] interface {
	Invoke(ctx context.Context, req Req) (Resp, error)
}

Endpoint represents a single RPC method.

func Chain

func Chain[Req any, Resp any](ep Endpoint[Req, Resp], middlewares ...Decorator[Req, Resp]) Endpoint[Req, Resp]

type Func added in v1.3.2

type Func[Req any, Resp any] func(ctx context.Context, req Req) (Resp, error)

The Func type is an adapter to allow the use of ordinary functions as Endpoint.

func (Func[Req, Resp]) Invoke added in v1.3.2

func (f Func[Req, Resp]) Invoke(ctx context.Context, req Req) (Resp, error)

Invoke calls f(ctx).

type Noop

type Noop[Req any, Resp any] struct{}

Noop is an endpoint that does nothing and returns a nil error.

func (Noop[Req, Resp]) Invoke

func (Noop[Req, Resp]) Invoke(context.Context, Req) (Resp, error)

Jump to

Keyboard shortcuts

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