common

package module
v0.0.0-...-9eea049 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: Apache-2.0 Imports: 15 Imported by: 41

README

GoshawkDB Common

This repo contains Go code which is common between the server and the Go client. It also contains the Capn'Proto definition files for communication between the server and all clients.

Documentation

Index

Constants

View Source
const (
	DefaultPort           = 7894
	DefaultPrometheusPort = 8080
	DefaultWSSPort        = 7895
	ProductVersion        = "dev" // protocol version!
	ProductName           = "GoshawkDB"
	HeartbeatInterval     = 2 * time.Second
	ConnectionBufferSize  = 131072
)
View Source
const (
	RMIdEmpty = RMId(0)
	KeyLen    = 20
	ClientLen = KeyLen - 8
)

Variables

View Source
var (
	VersionZero = MakeTxnId([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
)

Functions

func ConfigureSocket

func ConfigureSocket(socket *net.TCPConn) error

func SegToBytes

func SegToBytes(seg *capn.Segment) []byte

Types

type Capability

type Capability uint8
const (
	NoneCapability Capability = iota
	ReadOnlyCapability
	WriteOnlyCapability
	ReadWriteCapability
)

func NewCapability

func NewCapability(c msgs.Capability) Capability

func (Capability) AsMsg

func (c Capability) AsMsg() msgs.Capability

func (Capability) CanRead

func (c Capability) CanRead() bool

func (Capability) CanWrite

func (c Capability) CanWrite() bool

func (Capability) DenyRead

func (c Capability) DenyRead() Capability

func (Capability) DenyWrite

func (c Capability) DenyWrite() Capability

func (Capability) IsSubset

func (a Capability) IsSubset(b Capability) bool

returns b is a subset of a

func (Capability) String

func (c Capability) String() string

func (Capability) Union

func (a Capability) Union(b Capability) Capability

type ChannelWaitGroup

type ChannelWaitGroup struct {
	WaitChan chan struct{}
	// contains filtered or unexported fields
}

func NewChannelWaitGroup

func NewChannelWaitGroup() *ChannelWaitGroup

func (*ChannelWaitGroup) Add

func (cmg *ChannelWaitGroup) Add(delta uint64)

func (*ChannelWaitGroup) Done

func (cmg *ChannelWaitGroup) Done()

func (*ChannelWaitGroup) Wait

func (cmg *ChannelWaitGroup) Wait()

func (*ChannelWaitGroup) WaitUntilEither

func (cmg *ChannelWaitGroup) WaitUntilEither(other <-chan struct{})

type ClientId

type ClientId [ClientLen]byte

func MakeClientId

func MakeClientId(data []byte) *ClientId

func (ClientId) RMId

func (cid ClientId) RMId() RMId

func (ClientId) String

func (cid ClientId) String() string

type ClientIds

type ClientIds []ClientId

type Cmp

type Cmp int8
const (
	LT Cmp = iota - 1
	EQ
	GT
)

type Dialer

type Dialer interface {
	Dial() error
	Socket() net.Conn
	Close()
	Reset()
	RemoteHost() string
}

type Positions

type Positions capn.UInt8List

func (*Positions) Equal

func (a *Positions) Equal(b *Positions) bool

func (*Positions) String

func (p *Positions) String() string

type RMId

type RMId uint32

func (RMId) String

func (rmId RMId) String() string

type RMIds

type RMIds []RMId

func (RMIds) EmptyLen

func (rmIds RMIds) EmptyLen() int

func (RMIds) Equal

func (a RMIds) Equal(b RMIds) bool

func (RMIds) Len

func (rmIds RMIds) Len() int

func (RMIds) Less

func (rmIds RMIds) Less(i, j int) bool

func (RMIds) NonEmpty

func (rmIds RMIds) NonEmpty() RMIds

func (RMIds) NonEmptyLen

func (rmIds RMIds) NonEmptyLen() int

func (RMIds) Sort

func (rmIds RMIds) Sort()

func (RMIds) Swap

func (rmIds RMIds) Swap(i, j int)

type SocketMsgHandler

type SocketMsgHandler interface {
	ReadAndHandleOneMsg() error
}

type SocketReader

type SocketReader struct {
	SocketMsgHandler
	// contains filtered or unexported fields
}

func NewSocketReader

func NewSocketReader(conn actor.EnqueueFuncActor, smh SocketMsgHandler) *SocketReader

func (*SocketReader) Start

func (sr *SocketReader) Start()

func (*SocketReader) Stop

func (sr *SocketReader) Stop()

type SortUInt32

type SortUInt32 []uint32

func (SortUInt32) Len

func (nums SortUInt32) Len() int

func (SortUInt32) Less

func (nums SortUInt32) Less(i, j int) bool

func (SortUInt32) Sort

func (nums SortUInt32) Sort()

func (SortUInt32) Swap

func (nums SortUInt32) Swap(i, j int)

type TCPDialer

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

func NewTCPDialer

func NewTCPDialer(socket net.Conn, remoteHost string, logger log.Logger) *TCPDialer

func (*TCPDialer) Close

func (td *TCPDialer) Close()

func (*TCPDialer) Dial

func (td *TCPDialer) Dial() error

func (*TCPDialer) RemoteHost

func (td *TCPDialer) RemoteHost() string

func (*TCPDialer) Reset

func (td *TCPDialer) Reset()

func (*TCPDialer) Socket

func (td *TCPDialer) Socket() net.Conn

func (*TCPDialer) String

func (td *TCPDialer) String() string

type TLSCapnpBeater

type TLSCapnpBeater struct {
	*TLSCapnpHandshakerBase
	// contains filtered or unexported fields
}

func NewTLSCapnpBeater

func NewTLSCapnpBeater(tchb *TLSCapnpHandshakerBase, conn actor.EnqueueMsgActor, beatBytes []byte, drop bool) *TLSCapnpBeater

func (*TLSCapnpBeater) Exec

func (b *TLSCapnpBeater) Exec() (bool, error)

func (*TLSCapnpBeater) SendMessage

func (b *TLSCapnpBeater) SendMessage(msg []byte) error

func (*TLSCapnpBeater) Start

func (b *TLSCapnpBeater) Start()

func (*TLSCapnpBeater) Stop

func (b *TLSCapnpBeater) Stop()

type TLSCapnpHandshakerBase

type TLSCapnpHandshakerBase struct {
	Dialer
	// contains filtered or unexported fields
}

func NewTLSCapnpHandshakerBase

func NewTLSCapnpHandshakerBase(dialer Dialer) *TLSCapnpHandshakerBase

func (*TLSCapnpHandshakerBase) CreateBeater

func (tchb *TLSCapnpHandshakerBase) CreateBeater(conn actor.EnqueueMsgActor, beatBytes []byte, drop bool)

func (*TLSCapnpHandshakerBase) InternalShutdown

func (tchb *TLSCapnpHandshakerBase) InternalShutdown()

func (*TLSCapnpHandshakerBase) ReadExactlyOne

func (tchb *TLSCapnpHandshakerBase) ReadExactlyOne() (*capn.Segment, error)

this exists for handshake so that we don't accidentally read bits of the TLS handshake and break that!

func (*TLSCapnpHandshakerBase) ReadOne

func (tchb *TLSCapnpHandshakerBase) ReadOne() (*capn.Segment, error)

func (*TLSCapnpHandshakerBase) Reset

func (tchb *TLSCapnpHandshakerBase) Reset()

func (*TLSCapnpHandshakerBase) Send

func (tchb *TLSCapnpHandshakerBase) Send(msg []byte) error

func (*TLSCapnpHandshakerBase) SendMessage

func (tchb *TLSCapnpHandshakerBase) SendMessage(msg []byte) error

type TxnId

type TxnId [KeyLen]byte

func MakeTxnId

func MakeTxnId(data []byte) *TxnId

func (TxnId) BootCount

func (txnId TxnId) BootCount() uint32

func (TxnId) ClientId

func (txnId TxnId) ClientId(ifEmpty RMId) ClientId

func (*TxnId) Compare

func (a *TxnId) Compare(b *TxnId) Cmp

func (TxnId) ConnectionCount

func (txnId TxnId) ConnectionCount() uint32

func (*TxnId) IsZero

func (txnId *TxnId) IsZero() bool

func (TxnId) RMId

func (txnId TxnId) RMId(ifEmpty RMId) RMId

func (TxnId) String

func (txnId TxnId) String() string

type TxnIds

type TxnIds []*TxnId

func (TxnIds) Len

func (txnIds TxnIds) Len() int

func (TxnIds) Less

func (txnIds TxnIds) Less(i, j int) bool

func (TxnIds) Sort

func (txnIds TxnIds) Sort()

func (TxnIds) Swap

func (txnIds TxnIds) Swap(i, j int)

type VarUUId

type VarUUId [KeyLen]byte

func MakeVarUUId

func MakeVarUUId(data []byte) *VarUUId

func MakeVarUUIdFromStr

func MakeVarUUIdFromStr(str string) *VarUUId

func (*VarUUId) Compare

func (a *VarUUId) Compare(b *VarUUId) Cmp

func (VarUUId) String

func (vUUId VarUUId) String() string

type VarUUIds

type VarUUIds []*VarUUId

func (VarUUIds) Len

func (vUUIds VarUUIds) Len() int

func (VarUUIds) Less

func (vUUIds VarUUIds) Less(i, j int) bool

func (VarUUIds) Sort

func (vUUIds VarUUIds) Sort()

func (VarUUIds) Swap

func (vUUIds VarUUIds) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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