svcrouter

package
v0.0.0-...-20a20cb Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EA_REQUESTID    = "ri" // unique ID of the request
	EA_ORIGINATORID = "oi" // oi - originator ID
	EA_SERVICETYPE  = "st" // hash(com.extl.blah)
	EA_SERVICEID    = "si" // instance of service (e.g. multiple clusters)
	EA_SHARDID      = "sh" // Thing to hash on (empty = random)
	EA_SERVERID     = "se" // se - ID of particular server
	EA_ENDPOINTID   = "ep" // ID of a thread (multiple threads on same endpoint)
)
View Source
const (
	CM_ADD        = iota
	CM_DELETE     = iota
	CM_REPLACEALL = iota
	CM_DELETEALL  = iota
)
View Source
const (
	PT_CLIENTSNOENV     = "clientsnoenv" // a BIND peer expecting clients to connect and not provide an envelope
	PT_CLIENTSENV       = "clientsenv"   // a BIND peer expecting clients to connect and provide an envelope
	PT_DOWNSTREAMENV    = "downstreamenv"
	PT_DOWNSTREAMENVREP = "downstreamenvrep"
)
View Source
const (
	EN_VERSION = 0 // for serialization future compatibility
)

Variables

View Source
var ClientAttributeFilter = &AttributeFilter{
	Compulsory: map[string]bool{
		EA_ORIGINATORID: false,
		EA_SERVICETYPE:  true,
		EA_SERVICEID:    false,
		EA_SHARDID:      false,
	},
}
View Source
var DispatcherAttributeFilter = &AttributeFilter{
	Compulsory: map[string]bool{
		EA_SERVICETYPE: true,
		EA_SERVICEID:   true,
		EA_SHARDID:     false,
	},
}
View Source
var EndpointAttributeFilter = &AttributeFilter{
	Compulsory: map[string]bool{
		EA_SERVICETYPE: true,
		EA_SERVICEID:   true,
		EA_SHARDID:     false,
	},
}

Functions

func Barrier

func Barrier()

func DumpMsg

func DumpMsg(prefix string, msg [][]byte)

func DumpMsg(prefix string, msg [][]byte)

dump a message to the log

func InsertEnvelope

func InsertEnvelope(msg [][]byte, e *Envelope) ([][]byte, error)

func InsertLeadingDelimeter

func InsertLeadingDelimeter(msg [][]byte) [][]byte

func NewHalfPair

func NewHalfPair(c *zmq.Context, bind bool) (*zmq.Socket, string, error)

func NewPair

func NewPair(c *zmq.Context) (a *zmq.Socket, b *zmq.Socket, err error)

func NewPeerEntries

func NewPeerEntries() peerEntries

func NewServerEntries

func NewServerEntries() serverEntries

func NewSocketAndAddress

func NewSocketAndAddress(c *zmq.Context, bind bool, t zmq.Type, name string) (a *zmq.Socket, addr string, err error)

Types

type AttributeFilter

type AttributeFilter struct {
	Compulsory map[string]bool // set to true if compulsory, false if optional
}

type ComparableEnvelope

type ComparableEnvelope struct {
	Envelope
	// contains filtered or unexported fields
}

func (*ComparableEnvelope) Compare

func (ce *ComparableEnvelope) Compare(than *ComparableEnvelope) int

func (*ComparableEnvelope) EnsureSortOrder

func (ce *ComparableEnvelope) EnsureSortOrder()

func (*ComparableEnvelope) Equal

func (ce *ComparableEnvelope) Equal(than *ComparableEnvelope) bool

func (*ComparableEnvelope) Invalidate

func (ce *ComparableEnvelope) Invalidate()

func (*ComparableEnvelope) Less

func (ce *ComparableEnvelope) Less(than *ComparableEnvelope) bool

func (*ComparableEnvelope) MakeSortOrder

func (ce *ComparableEnvelope) MakeSortOrder()

type Envelope

type Envelope struct {
	Version    int               `json:"v"` // version of encoded header
	Attributes map[string]string `json:"a"` // attributes
}

func DecodeEnvelope

func DecodeEnvelope(data []byte) (*Envelope, error)

func FindEnvelope

func FindEnvelope(msg [][]byte) (*Envelope, int, error)

func NewEndpointEnvelope

func NewEndpointEnvelope(serviceType, serviceId, shardId string) *Envelope

func NewEnvelopeFromMsg

func NewEnvelopeFromMsg(msg [][]byte, filter *AttributeFilter) (*Envelope, error)

func RemoveEnvelope

func RemoveEnvelope(msg [][]byte) ([][]byte, *Envelope, error)

func (*Envelope) Encode

func (e *Envelope) Encode() ([]byte, error)

func (*Envelope) Has

func (e *Envelope) Has(k string) bool

func (*Envelope) IsEqual

func (e *Envelope) IsEqual(e2 *Envelope) bool

func (*Envelope) Validate

func (e *Envelope) Validate(filter *AttributeFilter) error

type Peer

type Peer struct {
	PeerDefinition
	// contains filtered or unexported fields
}

type PeerDefinition

type PeerDefinition struct {
	Name    string
	ZmqType zmq.Type
	Address string
	Bind    bool
	PeerImpl
}

func (*PeerDefinition) Equals

func (a *PeerDefinition) Equals(b *PeerDefinition) bool

type PeerImpl

type PeerImpl interface {
	GetType() PeerType
	PreDelete(re *RouterElement, peer *Peer)
	PostCreate(re *RouterElement, peer *Peer)
}

type PeerType

type PeerType string

type RouterElement

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

func NewRouterElement

func NewRouterElement(context *zmq.Context, bufferSize int, doRouting func(*RouterElement, *Peer, [][]byte) (*Peer, [][]byte, error)) (*RouterElement, error)

func (*RouterElement) AddPeer

func (re *RouterElement) AddPeer(def PeerDefinition) error

func (*RouterElement) Close

func (re *RouterElement) Close()

func (*RouterElement) DeleteAll

func (re *RouterElement) DeleteAll() error

func (*RouterElement) DeleteAllType

func (re *RouterElement) DeleteAllType(peerType PeerType) error

func (*RouterElement) DeletePeer

func (re *RouterElement) DeletePeer(name string) error

func (*RouterElement) GetPeer

func (re *RouterElement) GetPeer(name string) (*Peer, bool)

func (*RouterElement) ReplacePeers

func (re *RouterElement) ReplacePeers(peerType PeerType, defs []PeerDefinition) error

type ServerEntry

type ServerEntry struct {
	Peer     *Peer
	Slk      ServiceLookupKey
	ServerId string
	ShardId  string
	Priority int64
}

type ServiceDispatcher

type ServiceDispatcher struct {
	EnvRouterPeer   string
	NoEnvRouterPeer string
	ServiceRouter
	*RouterElement
	// contains filtered or unexported fields
}

func NewServiceDispatcher

func NewServiceDispatcher(context *zmq.Context, bufferSize int) (*ServiceDispatcher, error)

func (*ServiceDispatcher) AddPeer

func (sd *ServiceDispatcher) AddPeer(def PeerDefinition, peerType PeerType) error

func (*ServiceDispatcher) NewServiceDispatcherPeerImpl

func (sd *ServiceDispatcher) NewServiceDispatcherPeerImpl(peerType PeerType) *ServiceDispatcherPeerImpl

type ServiceDispatcherPeerImpl

type ServiceDispatcherPeerImpl struct {
	PeerType PeerType
	// contains filtered or unexported fields
}

func (*ServiceDispatcherPeerImpl) GetType

func (m *ServiceDispatcherPeerImpl) GetType() PeerType

func (*ServiceDispatcherPeerImpl) PostCreate

func (m *ServiceDispatcherPeerImpl) PostCreate(re *RouterElement, peer *Peer)

func (*ServiceDispatcherPeerImpl) PreDelete

func (m *ServiceDispatcherPeerImpl) PreDelete(re *RouterElement, peer *Peer)

type ServiceLookupKey

type ServiceLookupKey struct {
	ServiceType string
	ServiceId   string
}

type ServiceRouter

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

func NewServiceRouter

func NewServiceRouter() ServiceRouter

func (*ServiceRouter) AddService

func (sr *ServiceRouter) AddService(re *RouterElement, peerName string, e *Envelope) error

func (*ServiceRouter) DeleteAllPeerEntries

func (sr *ServiceRouter) DeleteAllPeerEntries(re *RouterElement, peerName string) error

func (*ServiceRouter) DeleteService

func (sr *ServiceRouter) DeleteService(re *RouterElement, peerName string, e *Envelope) error

func (*ServiceRouter) DeleteServiceStrings

func (sr *ServiceRouter) DeleteServiceStrings(re *RouterElement, peerName string, serviceType, serviceId, serverId, shardId string) error

func (*ServiceRouter) GetServerEntry

func (sr *ServiceRouter) GetServerEntry(serviceType, serviceId, shardId string) *ServerEntry

func (*ServiceRouter) LenPeerEntries

func (sr *ServiceRouter) LenPeerEntries(re *RouterElement, peerName string) int

func (*ServiceRouter) Validate

func (sr *ServiceRouter) Validate() error

Jump to

Keyboard shortcuts

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