Documentation ¶
Overview ¶
Package direct package provides the functionality to create a direct websocket connection to rmb relays without the need to rmb peers.
Index ¶
- Constants
- Variables
- func Challenge(env *types.Envelope) ([]byte, error)
- func GetEnvelope(ctx context.Context) *types.Envelope
- func GetTwinID(ctx context.Context) uint32
- func Json(response *types.Envelope, callBackErr error) ([]byte, error)
- func NewJWT(identity substrate.Identity, id uint32, session string, ttl uint32) (string, error)
- func Sign(signer substrate.Identity, input []byte) ([]byte, error)
- func VerifySignature(twinDB TwinDB, env *types.Envelope) error
- type Ed25519VerifyingKey
- type Handler
- type HandlerFunc
- type InnerConnection
- type Middleware
- type Peer
- type PeerOpt
- type Reader
- type RmbSigner
- type Router
- type RpcClient
- type Sr25519VerifyingKey
- type Twin
- type TwinDB
- type Verifier
- type Writer
Constants ¶
const ( KeyTypeEd25519 = "ed25519" KeyTypeSr25519 = "sr25519" )
const ( SignatureTypeEd25519 = "ed25519" SignatureTypeSr25519 = "sr25519" )
const CustomSigning = "RMB"
Variables ¶
var ( // ErrFunctionNotFound is an err returned if the handler function is not found ErrFunctionNotFound = fmt.Errorf("function is not found") )
Functions ¶
func GetEnvelope ¶
GetEnvelope gets an envelope from the context, panics if it's not there
Types ¶
type Ed25519VerifyingKey ¶
type Ed25519VerifyingKey []byte
type Handler ¶
Handler is a call back that is called with verified and decrypted incoming messages. An error can be non-nil error if verification or decryption failed
type HandlerFunc ¶
Handler is a handler function type
type InnerConnection ¶
type InnerConnection struct {
// contains filtered or unexported fields
}
InnerConnection holds the required state to create a self healing websocket connection to the rmb relay.
func NewConnection ¶
func NewConnection(identity substrate.Identity, url string, session string, twinID uint32) InnerConnection
NewConnection creates a new InnerConnection instance
type Middleware ¶
Middleware is middleware function type
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer exposes the functionality to talk directly to an rmb relay
func NewPeer ¶
func NewPeer( ctx context.Context, mnemonics string, subManager substrate.Manager, handler Handler, opts ...PeerOpt) (*Peer, error)
NewPeer creates a new RMB peer client. It connects directly to the RMB-Relay, and tries to reconnect if the connection broke.
You can close the connection by canceling the passed context.
Make sure the context passed to Call() does not outlive the directClient's context. Call() will panic if called while the directClient's context is canceled.
type PeerOpt ¶ added in v0.11.10
type PeerOpt func(*peerCfg)
func WithEncoder ¶ added in v0.11.10
WithEncoder sets encoding of the payload default is application/json
func WithEncryption ¶ added in v0.11.10
enable or disable encryption, default is enabled
func WithKeyType ¶ added in v0.11.10
WithKeyType set up the menmonic key type, default is Sr25519
func WithSession ¶ added in v0.11.10
WithSession set a custom session name, default is the nil session
func WithTwinCache ¶ added in v0.14.4
WithTwinCache cache twin information for this ttl number of seconds by default twins are cached in memory forever
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) SubRoute ¶
SubRoute add a route prefix to include more sub routes with handler from it
func (*Router) WithHandler ¶
func (r *Router) WithHandler(subCommand string, handler HandlerFunc)
WithHandler adds a handler function to a router sub command
type RpcClient ¶ added in v0.13.11
type RpcClient struct {
// contains filtered or unexported fields
}
RpcClient is a peer connection that makes it easy to make rpc calls
func NewRpcClient ¶
func NewRpcClient( ctx context.Context, mnemonics string, subManager substrate.Manager, opts ...PeerOpt) (*RpcClient, error)
NewRpcClient create a new rpc client the rpc client is a full peer, but provide a custom handler to make it easy to make rpc calls
type Sr25519VerifyingKey ¶
type Sr25519VerifyingKey []byte