Documentation ¶
Index ¶
- Constants
- func SignData(privateKey *ecdsa.PrivateKey, data ...[]byte) ([]byte, error)
- func SignMessage(msgBody *MessageBody, privateKey *ecdsa.PrivateKey) ([]byte, error)
- func ToHttpErrorCode(errorCode ErrorCode) int
- func ToJsonRPCErrorCode(errorCode ErrorCode) int
- func ValidateMessageSignature(msg *Message) error
- func ValidateSignature(signature []byte, data ...[]byte) (signerAddress []byte, err error)
- func ValidatedGatewaySpec(tomlString string) (job.Job, error)
- type Codec
- type ConnectionManager
- type ConnectionManagerConfig
- type DONConfig
- type DONConnectionManager
- type Delegate
- func (d *Delegate) AfterJobCreated(spec job.Job)
- func (d *Delegate) BeforeJobCreated(spec job.Job)
- func (d *Delegate) BeforeJobDeleted(spec job.Job)
- func (d *Delegate) JobType() job.Type
- func (d *Delegate) OnDeleteJob(spec job.Job, q pg.Queryer) error
- func (d *Delegate) ServicesForSpec(spec job.Job) (services []job.ServiceCtx, err error)
- type ErrorCode
- type Gateway
- type GatewayConfig
- type Handler
- type HandlerType
- type JsonRPCCodec
- func (*JsonRPCCodec) DecodeRequest(msgBytes []byte) (*Message, error)
- func (*JsonRPCCodec) DecodeResponse(msgBytes []byte) (*Message, error)
- func (*JsonRPCCodec) EncodeNewErrorResponse(id string, code int, message string, data []byte) ([]byte, error)
- func (*JsonRPCCodec) EncodeRequest(msg *Message) ([]byte, error)
- func (*JsonRPCCodec) EncodeResponse(msg *Message) ([]byte, error)
- type JsonRPCError
- type JsonRPCRequest
- type JsonRPCResponse
- type Message
- type MessageBody
- type NodeConfig
- type UserCallbackPayload
Constants ¶
const ( MessageSignatureLen = 65 MessageSignatureHexEncodedLen = 2 + 2*MessageSignatureLen MessageIdMaxLen = 128 MessageMethodMaxLen = 64 MessageDonIdMaxLen = 64 MessageSenderLen = 20 MessageSenderHexEncodedLen = 2 + 2*MessageSenderLen )
Variables ¶
This section is empty.
Functions ¶
func SignMessage ¶
func SignMessage(msgBody *MessageBody, privateKey *ecdsa.PrivateKey) ([]byte, error)
Message signatures are over the following data:
- MessageId aligned to 128 bytes
- Method aligned to 64 bytes
- DonId aligned to 64 bytes
- Payload (before parsing)
func ToHttpErrorCode ¶
func ToJsonRPCErrorCode ¶
func ValidateSignature ¶
Types ¶
type Codec ¶
type Codec interface { DecodeRequest(msgBytes []byte) (*Message, error) EncodeRequest(msg *Message) ([]byte, error) DecodeResponse(msgBytes []byte) (*Message, error) EncodeResponse(msg *Message) ([]byte, error) EncodeNewErrorResponse(id string, code int, message string, data []byte) ([]byte, error) }
Codec implements (de)serialization of Message objects.
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 DONConfig ¶
type DONConfig struct { DonId string HandlerName string HandlerConfig json.RawMessage Members []NodeConfig }
type DONConnectionManager ¶
type Delegate ¶ added in v2.3.0
type Delegate struct {
// contains filtered or unexported fields
}
func NewDelegate ¶ added in v2.3.0
func (*Delegate) AfterJobCreated ¶ added in v2.3.0
func (*Delegate) BeforeJobCreated ¶ added in v2.3.0
func (*Delegate) BeforeJobDeleted ¶ added in v2.3.0
func (*Delegate) OnDeleteJob ¶ added in v2.3.0
func (*Delegate) ServicesForSpec ¶ added in v2.3.0
ServicesForSpec returns the scheduler to be used for running observer jobs
type Gateway ¶
type Gateway interface { job.ServiceCtx gw_net.HTTPRequestHandler }
func NewGateway ¶
func NewGateway(codec 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 *Message, callbackCh chan<- UserCallbackPayload) error // Handlers should not make any assumptions about goroutines calling HandleNodeMessage HandleNodeMessage(ctx context.Context, msg *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 JsonRPCCodec ¶
type JsonRPCCodec struct { }
func (*JsonRPCCodec) DecodeRequest ¶
func (*JsonRPCCodec) DecodeRequest(msgBytes []byte) (*Message, error)
func (*JsonRPCCodec) DecodeResponse ¶
func (*JsonRPCCodec) DecodeResponse(msgBytes []byte) (*Message, error)
func (*JsonRPCCodec) EncodeNewErrorResponse ¶
func (*JsonRPCCodec) EncodeRequest ¶
func (*JsonRPCCodec) EncodeRequest(msg *Message) ([]byte, error)
func (*JsonRPCCodec) EncodeResponse ¶
func (*JsonRPCCodec) EncodeResponse(msg *Message) ([]byte, error)
type JsonRPCError ¶
type JsonRPCError struct { Code int `json:"code"` Message string `json:"message"` Data json.RawMessage `json:"data,omitempty"` }
JSON-RPC error can only be sent to users. It is not used for messages between Gateways and Nodes.
type JsonRPCRequest ¶
type JsonRPCRequest struct { Version string `json:"jsonrpc"` Id string `json:"id"` Method string `json:"method"` Params *Message `json:"params,omitempty"` }
Wrapping/unwrapping Message objects into JSON RPC ones folllowing https://www.jsonrpc.org/specification
type JsonRPCResponse ¶
type JsonRPCResponse struct { Version string `json:"jsonrpc"` Id string `json:"id"` Result *Message `json:"result,omitempty"` Error *JsonRPCError `json:"error,omitempty"` }
type Message ¶
type Message struct { Signature string `json:"signature"` Body MessageBody `json:"body"` }
* Top-level Message structure containing: * - universal fields identifying the request, the sender and the target DON/service * - product-specific payload * * Signature and Sender are hex-encoded with a "0x" prefix.
type MessageBody ¶
type NodeConfig ¶
type UserCallbackPayload ¶
UserCallbackPayload is a response to user request sent to HandleUserMessage(). Each message needs to receive at most one response on the provided channel.