gateway

package
v2.2.0-mercury-20230608 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToHttpErrorCode

func ToHttpErrorCode(errorCode ErrorCode) int

See https://go.dev/src/net/http/status.go

func ValidatedGatewaySpec added in v2.3.0

func ValidatedGatewaySpec(tomlString string) (job.Job, error)

Types

type ConnectionManager

type ConnectionManager interface {
	job.ServiceCtx
	network.ConnectionAcceptor

	DONConnectionManager(donId string) DONConnectionManager
}

ConnectionManager holds all connections between Gateway and Nodes.

func NewConnectionManager

func NewConnectionManager(config *GatewayConfig, clock gw_common.Clock, lggr logger.Logger) (ConnectionManager, error)

type ConnectionManagerConfig

type ConnectionManagerConfig struct {
	AuthTimestampToleranceSec uint32
	AuthChallengeLen          uint32
}

type DONConfig

type DONConfig struct {
	DonId         string
	HandlerName   string
	HandlerConfig json.RawMessage
	Members       []NodeConfig
}

type DONConnectionManager

type DONConnectionManager interface {
	SetHandler(handler Handler)

	// Thread-safe.
	SendToNode(ctx context.Context, nodeAddress string, msg *api.Message) error
}

type Delegate added in v2.3.0

type Delegate struct {
	// contains filtered or unexported fields
}

func NewDelegate added in v2.3.0

func NewDelegate(chains evm.ChainSet, ks keystore.Eth, lggr logger.Logger) *Delegate

func (*Delegate) AfterJobCreated added in v2.3.0

func (d *Delegate) AfterJobCreated(spec job.Job)

func (*Delegate) BeforeJobCreated added in v2.3.0

func (d *Delegate) BeforeJobCreated(spec job.Job)

func (*Delegate) BeforeJobDeleted added in v2.3.0

func (d *Delegate) BeforeJobDeleted(spec job.Job)

func (*Delegate) JobType added in v2.3.0

func (d *Delegate) JobType() job.Type

func (*Delegate) OnDeleteJob added in v2.3.0

func (d *Delegate) OnDeleteJob(spec job.Job, q pg.Queryer) error

func (*Delegate) ServicesForSpec added in v2.3.0

func (d *Delegate) ServicesForSpec(spec job.Job) (services []job.ServiceCtx, err error)

ServicesForSpec returns the scheduler to be used for running observer jobs

type ErrorCode

type ErrorCode int
const (
	NoError ErrorCode = iota
	UserMessageParseError
	UnsupportedDONIdError
	InternalHandlerError
	RequestTimeoutError
	NodeReponseEncodingError
	FatalError
)

type Gateway

type Gateway interface {
	job.ServiceCtx
	gw_net.HTTPRequestHandler
}

func NewGateway

func NewGateway(codec api.Codec, httpServer gw_net.HttpServer, handlers map[string]Handler, connMgr ConnectionManager, lggr logger.Logger) Gateway

func NewGatewayFromConfig

func NewGatewayFromConfig(config *GatewayConfig, lggr logger.Logger) (Gateway, error)

type GatewayConfig

type GatewayConfig struct {
	UserServerConfig        gw_net.HTTPServerConfig
	NodeServerConfig        gw_net.WebSocketServerConfig
	ConnectionManagerConfig ConnectionManagerConfig
	Dons                    []DONConfig
}

type Handler

type Handler interface {
	job.ServiceCtx

	// Each user request is processed by a separate goroutine, which:
	//   1. calls HandleUserMessage
	//   2. waits on callbackCh with a timeout
	HandleUserMessage(ctx context.Context, msg *api.Message, callbackCh chan<- UserCallbackPayload) error

	// Handlers should not make any assumptions about goroutines calling HandleNodeMessage
	HandleNodeMessage(ctx context.Context, msg *api.Message, nodeAddr string) error
}

func NewDummyHandler

func NewDummyHandler(donConfig *DONConfig, connMgr DONConnectionManager) (Handler, error)

func NewHandler

func NewHandler(handlerType HandlerType, donConfig *DONConfig, connMgr DONConnectionManager) (Handler, error)

type HandlerType

type HandlerType = string
const (
	Dummy HandlerType = "dummy"
)

type NodeConfig

type NodeConfig struct {
	Name    string
	Address string
}

type UserCallbackPayload

type UserCallbackPayload struct {
	Msg     *api.Message
	ErrCode ErrorCode
	ErrMsg  string
}

UserCallbackPayload is a response to user request sent to HandleUserMessage(). Each message needs to receive at most one response on the provided channel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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