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 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 ErrorData
- type GoTypeFieldInfoMapper
- type Installer
- type Message
- type Options
- type PassThroughRouter
- type PolymorphicHandling
- 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) Constructor(_ ...)
- func (s *Scheduler) HandleConcurrent(_ *miruken.Handles, concurrent ConcurrentBatch, composer miruken.Handler) *promise.Promise[ScheduledResult]
- func (s *Scheduler) HandlePublish(_ *miruken.Handles, publish Published, composer miruken.Handler) (p *promise.Promise[miruken.Void], err error)
- func (s *Scheduler) HandleSequential(_ *miruken.Handles, sequential SequentialBatch, composer miruken.Handler) *promise.Promise[ScheduledResult]
- type SequentialBatch
- type Stash
- type TypeFieldInfo
Constants ¶
This section is empty.
Variables ¶
var ( FromError = miruken.To("api:error") ToError = miruken.From("api:error") )
var ( // ToTypeInfo requests type information for a type. ToTypeInfo = miruken.To("type:info") // Polymorphic returns a miruken.Builder that enables polymorphic messaging. Polymorphic miruken.Builder = miruken.Options(Options{ PolymorphicHandling: miruken.Set(PolymorphicHandlingRoot), }) )
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 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 ErrorData ¶ added in v0.11.0
type ErrorData struct {
Message string
}
ErrorData is the default error shape.
type GoTypeFieldInfoMapper ¶ added in v0.19.0
type GoTypeFieldInfoMapper struct{}
GoTypeFieldInfoMapper provides TypeFieldInfo using package and name.
func (*GoTypeFieldInfoMapper) GoTypeInfo ¶ added in v0.19.0
func (m *GoTypeFieldInfoMapper) GoTypeInfo( _ *struct { miruken.Maps miruken.Format `to:"type:info"` }, maps *miruken.Maps, ) (TypeFieldInfo, error)
type Message ¶ added in v0.11.0
type Message struct {
Payload any
}
Message is envelop for polymorphic payloads.
type Options ¶ added in v0.18.0
type Options struct { PolymorphicHandling miruken.Option[PolymorphicHandling] TypeInfoFormat string }
Options provide options for controlling api messaging.
type PassThroughRouter ¶
type PassThroughRouter struct{}
func (*PassThroughRouter) Pass ¶
func (p *PassThroughRouter) Pass( _ *struct { miruken.Handles miruken.SkipFilters Routes `scheme:"pass-through"` }, routed Routed, composer miruken.Handler, ) (any, miruken.HandleResult)
type PolymorphicHandling ¶ added in v0.11.0
type PolymorphicHandling uint8
PolymorphicHandling is an enum that determines if messages are augmented with type discriminators.
const ( PolymorphicHandlingNone PolymorphicHandling = 0 PolymorphicHandlingRoot PolymorphicHandling = 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) Constructor ¶
func (*Scheduler) HandleConcurrent ¶
func (s *Scheduler) HandleConcurrent( _ *miruken.Handles, concurrent ConcurrentBatch, composer miruken.Handler, ) *promise.Promise[ScheduledResult]
func (*Scheduler) HandlePublish ¶
func (*Scheduler) HandleSequential ¶
func (s *Scheduler) HandleSequential( _ *miruken.Handles, 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( _ *miruken.Handles, get *stashGet, ) miruken.HandleResult
Get retrieves an item by key. It 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 messages.