Documentation
¶
Overview ¶
Package router implements action routing to the designated processors.
Index ¶
- func SignResult(ar *types.ActionResult, signer node.Signer) (*types.ActionResponse, error)
- type ProcessFunc
- type Processor
- type Router
- func (r *Router) RegisterDefaultDirect(processor Processor)
- func (r *Router) RegisterDefaultInstruction(processor Processor)
- func (r *Router) RegisterDirectProcessor(opType op.Type, opCommand op.Command, processor direct.Processor)
- func (r *Router) RegisterInstructionProcessor(opType op.Type, opCommand op.Command, processor instructions.Processor)
- func (r *Router) RegisterProcessFunc(opType op.Type, opCommand op.Command, processFunc ProcessFunc)
- func (r *Router) RegisterProcessor(opType op.Type, opCommand op.Command, processor Processor)
- func (r Router) Run(signer node.Signer)
- func (r *Router) ServeQueue(id processorutils.QueueID, signer node.Signer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SignResult ¶
func SignResult(ar *types.ActionResult, signer node.Signer) (*types.ActionResponse, error)
SignResult signs the action result payload and returns an action response.
Types ¶
type ProcessFunc ¶
func (ProcessFunc) Process ¶
func (p ProcessFunc) Process(ctx context.Context, a *types.Action) types.ActionResult
Process calls the wrapped function to produce an action result.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router assigns an action to a designated processor based on its opType and opCommand.
Actions that do not have a designated processor are routed to defaultDirect or defaultInstruction based on action type.
func New ¶
func New(proxyURL *settings.ProxyURLMutex) Router
New creates a router associated with the provided proxy URL mutex.
func NewForwardRouter ¶
func NewForwardRouter(teeNode *pnode.Node, wStorage *wallets.Storage, pStorage *policy.Storage, extensionPort int, proxyURL *settings.ProxyURLMutex) Router
NewForwardRouter assembles a router that manages base actions and forwards remaining actions to the external extension service.
func NewPMWRouter ¶
func NewPMWRouter(teeNode *pnode.Node, wStorage *wallets.Storage, pStorage *policy.Storage, proxyURL *settings.ProxyURLMutex) Router
NewPMWRouter wires direct and instruction processors for the Protocol Managed Wallet service, without the extension defaults.
func (*Router) RegisterDefaultDirect ¶
RegisterDefaultDirect registers processor for direct actions, that do not have a designated processor.
func (*Router) RegisterDefaultInstruction ¶
RegisterDefaultInstruction registers processor for instruction actions, that do not have a designated processor.
func (*Router) RegisterDirectProcessor ¶
func (r *Router) RegisterDirectProcessor(opType op.Type, opCommand op.Command, processor direct.Processor)
RegisterDirectProcessor registers a direct processor for the given op pair.
func (*Router) RegisterInstructionProcessor ¶
func (r *Router) RegisterInstructionProcessor(opType op.Type, opCommand op.Command, processor instructions.Processor)
RegisterInstructionProcessor registers an instruction processor for the given op pair.
func (*Router) RegisterProcessFunc ¶
RegisterProcessFunc stores a ProcessFunc for the given op pair.
func (*Router) RegisterProcessor ¶
RegisterProcessor registers processor for the pair of opType and opCommand.
Only one processor per pair is allowed.
func (Router) Run ¶
Run spawns workers processing queues for both the instructions and direct instructions.
func (*Router) ServeQueue ¶
func (r *Router) ServeQueue(id processorutils.QueueID, signer node.Signer)
ServeQueue starts an endless loop that fetches actions from proxy's queue, processes them, and posts the response to the proxy.