Documentation ¶
Index ¶
- Variables
- func Concurrent(handler miruken.Handler, requests ...any) *promise.Promise[[]either.Either[error, any]]
- func Failure(val error) either.Either[error, any]
- func Feature(config ...func(installer *Installer)) miruken.Feature
- func ParseContentType(contentType string, direction maps.Direction) (*maps.Format, error)
- func Post(handler miruken.Handler, message any) (p *promise.Promise[miruken.Void], err error)
- func Publish(handler miruken.Handler, message any) (p *promise.Promise[miruken.Void], err error)
- func Send[TResponse any](handler miruken.Handler, request any) (r TResponse, pr *promise.Promise[TResponse], err error)
- func Sequential(handler miruken.Handler, requests ...any) *promise.Promise[[]either.Either[error, any]]
- func StashDrop[T any](handler miruken.Handler) error
- func StashDropKey(handler miruken.Handler, key any) (err error)
- func StashGet[T any](handler miruken.Handler) (t T, ok bool)
- func StashGetKey(handler miruken.Handler, key any) (val any, ok bool)
- func StashGetOrPut[T any](handler miruken.Handler, val T) (T, error)
- func StashGetOrPutFunc[T any](handler miruken.Handler, fun func() (T, *promise.Promise[T])) (T, *promise.Promise[T], error)
- func StashGetOrPutKey(handler miruken.Handler, key any, val any) (any, error)
- func StashGetOrPutKeyFunc(handler miruken.Handler, key any, fun func() (any, *promise.Promise[any])) (any, *promise.Promise[any], error)
- func StashPut[T any](handler miruken.Handler, val T) error
- func StashPutKey(handler miruken.Handler, key any, val any) error
- func Success[R any](val R) either.Either[error, R]
- type ConcurrentBatch
- type GoPolymorphism
- type Installer
- type MalformedErrorError
- type Message
- type Options
- type PassThroughRouter
- type Polymorphism
- type Published
- type RouteReply
- type Routed
- type Routes
- func (r *Routes) AppliesTo(callback miruken.Callback) bool
- func (r *Routes) Filters(binding miruken.Binding, callback any, composer miruken.Handler) ([]miruken.Filter, error)
- func (r *Routes) InitWithTag(tag reflect.StructTag) error
- func (r *Routes) Required() bool
- func (r *Routes) Satisfies(routed Routed) bool
- type ScheduledResult
- type Scheduler
- func (s *Scheduler) Concurrent(_ *handles.It, concurrent ConcurrentBatch, composer miruken.Handler) *promise.Promise[ScheduledResult]
- func (s *Scheduler) Constructor(_ ...)
- func (s *Scheduler) New(_ ..., create *creates.It) any
- func (s *Scheduler) Publish(_ *handles.It, publish Published, composer miruken.Handler) (p *promise.Promise[miruken.Void], err error)
- func (s *Scheduler) Sequential(_ *handles.It, sequential SequentialBatch, composer miruken.Handler) *promise.Promise[ScheduledResult]
- type SequentialBatch
- type Stash
- type Surrogate
- type TypeFieldInfo
- type UnknownTypeIdError
Constants ¶
This section is empty.
Variables ¶
var ( // Polymorphic request encoding to include type information. Polymorphic = miruken.Options(Options{ Polymorphism: miruken.Set(PolymorphismRoot), }) // ToTypeInfo requests the type discriminator for a type. ToTypeInfo = maps.To("type:info", nil) )
var ( ToJson = maps.To("application/json", nil) FromJson = maps.From("application/json", nil) )
var (
ErrMissingResponse = errors.New("missing batch response")
)
Functions ¶
func Concurrent ¶
func Concurrent( handler miruken.Handler, requests ...any, ) *promise.Promise[[]either.Either[error, any]]
Concurrent processes a batch of requests concurrently. Returns a batch of corresponding responses (or errors).
func ParseContentType ¶ added in v0.24.0
ParseContentType parses the contentType into a maps.Format suitable for mapping in the direction.
func Post ¶
Post sends a message without an expected response. A new Stash is created to manage any transit state. Returns an empty promise if the call is asynchronous.
func Publish ¶
Publish sends a message to all recipients. A new Stash is created to manage any transit state. Returns an empty promise if the call is asynchronous.
func Send ¶
func Send[TResponse any]( handler miruken.Handler, request any, ) (r TResponse, pr *promise.Promise[TResponse], err error)
Send sends a request with an expected response. A new Stash is created to manage any transit state. Returns the TResponse if the call is synchronous or a promise of TResponse if the call is asynchronous.
func Sequential ¶
func Sequential( handler miruken.Handler, requests ...any, ) *promise.Promise[[]either.Either[error, any]]
Sequential processes a batch of requests sequentially. Returns a batch of corresponding responses (or errors).
func StashGetOrPutFunc ¶
func StashGetOrPutKey ¶
func StashGetOrPutKeyFunc ¶
Types ¶
type ConcurrentBatch ¶
type ConcurrentBatch struct {
Requests []any
}
ConcurrentBatch represents a batch of requests to execute concurrently. The operation returns after all requests are completed and includes all successes and failures.
type GoPolymorphism ¶ added in v0.24.0
type GoPolymorphism struct{}
GoPolymorphism provides polymorphic support for GO types.
func (*GoPolymorphism) Dynamic ¶ added in v0.24.0
func (m *GoPolymorphism) Dynamic( _ *struct { miruken.Strict creates.It }, create *creates.It, ctx miruken.HandleContext, ) any
func (*GoPolymorphism) Static ¶ added in v0.24.0
func (m *GoPolymorphism) Static( _ *struct { miruken.Strict b creates.It `key:"bool"` i creates.It `key:"int"` i8 creates.It `key:"int8"` i16 creates.It `key:"int16"` i32 creates.It `key:"int32"` i64 creates.It `key:"int64"` ui creates.It `key:"uint"` ui8 creates.It `key:"uint8"` ui16 creates.It `key:"uint16"` ui32 creates.It `key:"uint32"` ui64 creates.It `key:"uint64"` f32 creates.It `key:"float32"` f64 creates.It `key:"float64"` st creates.It `key:"string"` a creates.It `key:"interface {}"` bs creates.It `key:"[]bool"` is creates.It `key:"[]int"` i8s creates.It `key:"[]int8"` i16s creates.It `key:"[]int16"` i32s creates.It `key:"[]int32"` i64s creates.It `key:"[]int64"` uis creates.It `key:"[]uint"` ui8s creates.It `key:"[]uint8"` ui16s creates.It `key:"[]uint16"` ui32s creates.It `key:"[]uint32"` ui64s creates.It `key:"[]uint64"` f32s creates.It `key:"[]float32"` f64s creates.It `key:"[]float64"` sts creates.It `key:"[]string"` as creates.It `key:"[]interface {}"` }, create *creates.It, ) any
type MalformedErrorError ¶ added in v0.22.0
type MalformedErrorError struct {
Culprit any
}
MalformedErrorError reports an invalid error payload.
func (*MalformedErrorError) Error ¶ added in v0.22.0
func (e *MalformedErrorError) Error() string
type Message ¶ added in v0.11.0
type Message struct {
Payload any
}
Message is an envelope for polymorphic payloads.
type Options ¶ added in v0.18.0
type Options struct { Polymorphism miruken.Option[Polymorphism] TypeInfoFormat string TypeFieldValue string }
Options provide options for controlling api messaging.
type PassThroughRouter ¶
type PassThroughRouter struct{}
func (*PassThroughRouter) Pass ¶
func (p *PassThroughRouter) Pass( _ *struct { handles.It miruken.SkipFilters Routes `scheme:"pass-through"` }, routed Routed, composer miruken.Handler, ) (any, miruken.HandleResult)
type Polymorphism ¶ added in v0.20.0
type Polymorphism uint8
Polymorphism is an enum that defines how type discriminators are included in polymorphic messages.
const ( PolymorphismNone Polymorphism = 0 PolymorphismRoot Polymorphism = 1 << iota )
type Published ¶
type Published struct {
Message any
}
Published marks a message to be published to all consumers.
type RouteReply ¶
RouteReply holds the responses for a route.
type Routes ¶
type Routes struct {
// contains filtered or unexported fields
}
Routes is a FilterProvider of routesFilter.
type ScheduledResult ¶
ScheduledResult represents the results of a scheduled request. The result is either an error (if fails) or success value.
type Scheduler ¶
type Scheduler struct{}
Scheduler performs the scheduling of requests.
func (*Scheduler) Concurrent ¶ added in v0.22.0
func (s *Scheduler) Concurrent( _ *handles.It, concurrent ConcurrentBatch, composer miruken.Handler, ) *promise.Promise[ScheduledResult]
func (*Scheduler) Constructor ¶
func (*Scheduler) Sequential ¶ added in v0.22.0
func (s *Scheduler) Sequential( _ *handles.It, sequential SequentialBatch, composer miruken.Handler, ) *promise.Promise[ScheduledResult]
type SequentialBatch ¶
type SequentialBatch struct {
Requests []any
}
SequentialBatch represents a batch of requests to execute sequentially. The operation aborts after the first failure and returns the successfully completed responses and first failure.
type Stash ¶
type Stash struct {
// contains filtered or unexported fields
}
Stash is a transient storage of data.
func NewStash ¶
NewStash creates a new Stash. When root is true, retrieval will not fail if not found.
func (*Stash) Get ¶
func (s *Stash) Get( _ *handles.It, get *stashGet, ) miruken.HandleResult
Get retrieves an item by key. Build is considered NotHandled if an item with the key is not found and this Stash is not rooted. This allows retrieval to propagate up the chain.
func (*Stash) NoConstructor ¶
func (s *Stash) NoConstructor()
NoConstructor prevents Stash from being created implicitly.
type TypeFieldInfo ¶ added in v0.16.0
TypeFieldInfo defines metadata for polymorphic serialization.
type UnknownTypeIdError ¶ added in v0.21.0
UnknownTypeIdError reports an invalid type discriminator.
func (*UnknownTypeIdError) Error ¶ added in v0.21.0
func (e *UnknownTypeIdError) Error() string
func (*UnknownTypeIdError) Unwrap ¶ added in v0.21.0
func (e *UnknownTypeIdError) Unwrap() error