Skip to content

Commit

Permalink
Add experimental tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Feb 5, 2025
1 parent d1f86a6 commit cb760d1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nexus/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
type NoValue *struct{}

// OperationOptions contains the general options for an operation, across different handlers.
//
// NOTE: Experimental
type OperationOptions struct {
// ServiceName is the name of the service that contains the operation.
ServiceName string
Expand All @@ -32,6 +34,10 @@ type OperationOptions struct {
Header Header
}

// MiddlewareFunc is a function which receives an OperationInvoker and returns another OperationInvoker.
// If the middleware wants to stop the chain before any handler is called, it can return an error.
//
// NOTE: Experimental
type MiddlewareFunc func(OperationOptions, OperationInvoker[any, any]) (OperationInvoker[any, any], error)

// OperationReference provides a typed interface for invoking operations. Every [Operation] is also an
Expand Down Expand Up @@ -241,6 +247,8 @@ func (r *ServiceRegistry) Register(services ...*Service) error {
}

// Use registers middleware to be applied to all operations. Middleware is called for each operation invocation.
//
// NOTE: Experimental
func (s *ServiceRegistry) Use(middleWare ...MiddlewareFunc) {
s.middleware = append(s.middleware, middleWare...)
}
Expand Down

0 comments on commit cb760d1

Please sign in to comment.