service

package
v0.0.0-...-782863c Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package service defines the generic interface for node services.

Index

Constants

This section is empty.

Variables

View Source
var CONNECTION_name = map[int32]string{
	0: "UNKNOWN",
	1: "BROADCAST",
	2: "SBAC",
	3: "KV",
	4: "CHECKER",
}
View Source
var CONNECTION_value = map[string]int32{
	"UNKNOWN":   0,
	"BROADCAST": 1,
	"SBAC":      2,
	"KV":        3,
	"CHECKER":   4,
}

Functions

This section is empty.

Types

type CONNECTION

type CONNECTION int32
const (
	CONNECTION_UNKNOWN   CONNECTION = 0
	CONNECTION_BROADCAST CONNECTION = 1
	CONNECTION_SBAC      CONNECTION = 2
	CONNECTION_KV        CONNECTION = 3
	CONNECTION_CHECKER   CONNECTION = 4
)

func (CONNECTION) EnumDescriptor

func (CONNECTION) EnumDescriptor() ([]byte, []int)

func (CONNECTION) String

func (x CONNECTION) String() string

type Handler

type Handler interface {
	Handle(peerID uint64, msg *Message) (*Message, error)
	Name() string
}

Handler specifies the interface for a node service.

type Hello

type Hello struct {
	Agent                string     `protobuf:"bytes,1,opt,name=agent,proto3" json:"agent,omitempty"`
	Payload              []byte     `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	Signature            []byte     `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
	Type                 CONNECTION `protobuf:"varint,4,opt,name=type,proto3,enum=service.CONNECTION" json:"type,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func SignHello

func SignHello(clientID uint64, serverID uint64, key signature.KeyPair, c CONNECTION) (*Hello, error)

SignHello returns a signed payload for use as a Hello in a service connection.

func (*Hello) Descriptor

func (*Hello) Descriptor() ([]byte, []int)

func (*Hello) GetAgent

func (m *Hello) GetAgent() string

func (*Hello) GetPayload

func (m *Hello) GetPayload() []byte

func (*Hello) GetSignature

func (m *Hello) GetSignature() []byte

func (*Hello) GetType

func (m *Hello) GetType() CONNECTION

func (*Hello) ProtoMessage

func (*Hello) ProtoMessage()

func (*Hello) Reset

func (m *Hello) Reset()

func (*Hello) String

func (m *Hello) String() string

func (*Hello) XXX_DiscardUnknown

func (m *Hello) XXX_DiscardUnknown()

func (*Hello) XXX_Marshal

func (m *Hello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Hello) XXX_Merge

func (dst *Hello) XXX_Merge(src proto.Message)

func (*Hello) XXX_Size

func (m *Hello) XXX_Size() int

func (*Hello) XXX_Unmarshal

func (m *Hello) XXX_Unmarshal(b []byte) error

type HelloInfo

type HelloInfo struct {
	Client               uint64    `protobuf:"varint,1,opt,name=client,proto3" json:"client,omitempty"`
	Nonce                []byte    `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
	Server               uint64    `protobuf:"varint,3,opt,name=server,proto3" json:"server,omitempty"`
	Timestamp            time.Time `protobuf:"bytes,4,opt,name=timestamp,stdtime" json:"timestamp"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*HelloInfo) Descriptor

func (*HelloInfo) Descriptor() ([]byte, []int)

func (*HelloInfo) GetClient

func (m *HelloInfo) GetClient() uint64

func (*HelloInfo) GetNonce

func (m *HelloInfo) GetNonce() []byte

func (*HelloInfo) GetServer

func (m *HelloInfo) GetServer() uint64

func (*HelloInfo) GetTimestamp

func (m *HelloInfo) GetTimestamp() time.Time

func (*HelloInfo) ProtoMessage

func (*HelloInfo) ProtoMessage()

func (*HelloInfo) Reset

func (m *HelloInfo) Reset()

func (*HelloInfo) String

func (m *HelloInfo) String() string

func (*HelloInfo) XXX_DiscardUnknown

func (m *HelloInfo) XXX_DiscardUnknown()

func (*HelloInfo) XXX_Marshal

func (m *HelloInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HelloInfo) XXX_Merge

func (dst *HelloInfo) XXX_Merge(src proto.Message)

func (*HelloInfo) XXX_Size

func (m *HelloInfo) XXX_Size() int

func (*HelloInfo) XXX_Unmarshal

func (m *HelloInfo) XXX_Unmarshal(b []byte) error

type Message

type Message struct {
	ID                   uint64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Error                string   `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	Opcode               int32    `protobuf:"varint,3,opt,name=opcode,proto3" json:"opcode,omitempty"`
	Payload              []byte   `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func EncodeMessage

func EncodeMessage(opcode int32, pb proto.Message) *Message

EncodeMessage takes a protobuf-compatible struct and encodes it into a service Message.

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetError

func (m *Message) GetError() string

func (*Message) GetID

func (m *Message) GetID() uint64

func (*Message) GetOpcode

func (m *Message) GetOpcode() int32

func (*Message) GetPayload

func (m *Message) GetPayload() []byte

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (dst *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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