Documentation ¶
Index ¶
- func RegisterStream[IN, OUT Message, S State[A], A Action](setupCtx *SetupContext[S, A], h StreamHandler[S, A, IN, OUT], ...)
- func RegisterUnary[IN, OUT Message, S State[A], A Action](setupCtx *SetupContext[S, A], h UnaryHandler[S, A, IN, OUT], ...)
- type Action
- type CORSConfig
- type CompressionLevel
- type DecoderFunc
- type Error
- type InitState
- type Message
- type PushOpt
- type RESTParam
- type RESTParams
- type Selector
- type Server
- type ServerOption
- func Listen(addr string) ServerOption
- func WithCORS(cors CORSConfig) ServerOption
- func WithCompression(lvl CompressionLevel) ServerOption
- func WithCustomRPC(in kit.IncomingRPCFactory, out kit.OutgoingRPCFactory) ServerOption
- func WithPredicateKey(key string) ServerOption
- func WithServerName(name string) ServerOption
- func WithWebsocketEndpoint(endpoint string) ServerOption
- type SetupContext
- type State
- type StreamCtx
- func (c *StreamCtx) Conn() kit.Conn
- func (c *StreamCtx) Context() context.Context
- func (c *StreamCtx) Next()
- func (c *StreamCtx[S, A, M]) Push(m M, opt ...PushOpt) S
- func (c *StreamCtx[S, A, M]) PushTo(conn kit.Conn, m M, opt ...PushOpt)
- func (c *StreamCtx) ReduceState(action A, fn func(s S) error) (err error)
- func (c *StreamCtx) Route() string
- func (c *StreamCtx) SetUserContext(userCtx context.Context)
- func (c *StreamCtx) State() S
- type StreamHandler
- type StreamOption
- type StreamSelectorOption
- type UnaryCtx
- func (c *UnaryCtx) Conn() kit.Conn
- func (c *UnaryCtx) Context() context.Context
- func (c *UnaryCtx) Next()
- func (c *UnaryCtx[S, A]) RESTConn() (kit.RESTConn, bool)
- func (c *UnaryCtx) ReduceState(action A, fn func(s S) error) (err error)
- func (c *UnaryCtx) Route() string
- func (c *UnaryCtx) SetUserContext(userCtx context.Context)
- func (c *UnaryCtx) State() S
- type UnaryHandler
- type UnaryOption
- func DELETE(path string, opt ...UnarySelectorOption) UnaryOption
- func GET(path string, opt ...UnarySelectorOption) UnaryOption
- func HEAD(path string, opt ...UnarySelectorOption) UnaryOption
- func OPTIONS(path string, opt ...UnarySelectorOption) UnaryOption
- func PATCH(path string, opt ...UnarySelectorOption) UnaryOption
- func POST(path string, opt ...UnarySelectorOption) UnaryOption
- func PUT(path string, opt ...UnarySelectorOption) UnaryOption
- func REST(method, path string, opt ...UnarySelectorOption) UnaryOption
- type UnarySelectorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterStream ¶
func RegisterStream[IN, OUT Message, S State[A], A Action]( setupCtx *SetupContext[S, A], h StreamHandler[S, A, IN, OUT], opt ...StreamOption, )
func RegisterUnary ¶
func RegisterUnary[IN, OUT Message, S State[A], A Action]( setupCtx *SetupContext[S, A], h UnaryHandler[S, A, IN, OUT], opt ...UnaryOption, )
Types ¶
type CORSConfig ¶
type CORSConfig = fasthttp.CORSConfig
type CompressionLevel ¶
type CompressionLevel = fasthttp.CompressionLevel
const ( CompressionLevelDisabled CompressionLevel = -1 CompressionLevelDefault CompressionLevel = 0 CompressionLevelBestSpeed CompressionLevel = 1 CompressionLevelBestCompression CompressionLevel = 2 )
Represents compression level that will be used in the middleware
type DecoderFunc ¶
type DecoderFunc func(bag RESTParams, data []byte) (kit.Message, error)
type InitState ¶
func ToInitiateState ¶
type PushOpt ¶
func WithHdrMap ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
func (*Server) PostmanCollection ¶
func (*Server) SwaggerAPI ¶
type ServerOption ¶
type ServerOption func(cfg *serverConfig)
func Listen ¶
func Listen(addr string) ServerOption
func WithCORS ¶
func WithCORS(cors CORSConfig) ServerOption
func WithCompression ¶
func WithCompression(lvl CompressionLevel) ServerOption
func WithCustomRPC ¶
func WithCustomRPC(in kit.IncomingRPCFactory, out kit.OutgoingRPCFactory) ServerOption
func WithPredicateKey ¶
func WithPredicateKey(key string) ServerOption
func WithServerName ¶
func WithServerName(name string) ServerOption
func WithWebsocketEndpoint ¶
func WithWebsocketEndpoint(endpoint string) ServerOption
type SetupContext ¶
SetupContext is a context object which is holding information until the Server starts. It is used internally to hold state and server configuration.
type StreamCtx ¶
type StreamCtx[S State[A], A Action, M Message] struct { // contains filtered or unexported fields }
func (*StreamCtx) ReduceState ¶
ReduceState is a helper function to reduce state and call fn if it's not nil. If you need to reduce the state in an atomic fashion, then you should pass a function fn which is guaranteed to be called in a locked state. Although, it only works if S implements sync.Locker interface.
func (*StreamCtx) SetUserContext ¶
type StreamHandler ¶
type StreamOption ¶
Exposing internal types
func RPC ¶
func RPC(predicate string, opt ...StreamSelectorOption) StreamOption
type StreamSelectorOption ¶
type StreamSelectorOption = stream.SelectorOption
Exposing internal types
func StreamDecoder ¶
func StreamDecoder(decoder DecoderFunc) StreamSelectorOption
type UnaryCtx ¶
func (*UnaryCtx) ReduceState ¶
ReduceState is a helper function to reduce state and call fn if it's not nil. If you need to reduce the state in an atomic fashion, then you should pass a function fn which is guaranteed to be called in a locked state. Although, it only works if S implements sync.Locker interface.
func (*UnaryCtx) SetUserContext ¶
type UnaryHandler ¶
type UnaryOption ¶
Exposing internal types
func DELETE ¶
func DELETE(path string, opt ...UnarySelectorOption) UnaryOption
func GET ¶
func GET(path string, opt ...UnarySelectorOption) UnaryOption
func HEAD ¶
func HEAD(path string, opt ...UnarySelectorOption) UnaryOption
func OPTIONS ¶
func OPTIONS(path string, opt ...UnarySelectorOption) UnaryOption
func PATCH ¶
func PATCH(path string, opt ...UnarySelectorOption) UnaryOption
func POST ¶
func POST(path string, opt ...UnarySelectorOption) UnaryOption
func PUT ¶
func PUT(path string, opt ...UnarySelectorOption) UnaryOption
func REST ¶
func REST(method, path string, opt ...UnarySelectorOption) UnaryOption
type UnarySelectorOption ¶
type UnarySelectorOption = unary.SelectorOption
Exposing internal types
func UnaryDecoder ¶
func UnaryDecoder(decoder DecoderFunc) UnarySelectorOption
func UnaryName ¶
func UnaryName(name string) UnarySelectorOption