router

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package router implements action routing to the designated processors.

Index

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

type ProcessFunc func(ctx context.Context, a *types.Action) types.ActionResult

func (ProcessFunc) Process

Process calls the wrapped function to produce an action result.

type Processor

type Processor interface {
	Process(ctx context.Context, a *types.Action) types.ActionResult
}

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

func (r *Router) RegisterDefaultDirect(processor Processor)

RegisterDefaultDirect registers processor for direct actions, that do not have a designated processor.

func (*Router) RegisterDefaultInstruction

func (r *Router) RegisterDefaultInstruction(processor Processor)

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

func (r *Router) RegisterProcessFunc(opType op.Type, opCommand op.Command, processFunc ProcessFunc)

RegisterProcessFunc stores a ProcessFunc for the given op pair.

func (*Router) RegisterProcessor

func (r *Router) RegisterProcessor(opType op.Type, opCommand op.Command, processor Processor)

RegisterProcessor registers processor for the pair of opType and opCommand.

Only one processor per pair is allowed.

func (Router) Run

func (r Router) Run(signer node.Signer)

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.

Directories

Path Synopsis
queue package implements functions for interacting with proxy's internal endpoints.
queue package implements functions for interacting with proxy's internal endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL