Documentation
¶
Index ¶
- Variables
- func NoLogging()
- func SetLogWriter(w io.Writer)
- func ToggleLineNumberPrinting(info, warn, fail, debug bool)
- type Nan0
- type NanoBuilder
- func (sec *NanoBuilder) AddMessageIdentities(messageIdents ...proto.Message) *NanoBuilder
- func (sec *NanoBuilder) AddMessageIdentity(messageIdent proto.Message) *NanoBuilder
- func (sec NanoBuilder) Build() (nan0 NanoServiceWrapper, err error)
- func (sec *NanoBuilder) BuildServer(handler func(net.Listener, *NanoBuilder)) (*NanoServer, error)
- func (sec *NanoBuilder) ReceiveBuffer(receiveBuffer int) *NanoBuilder
- func (sec *NanoBuilder) SendBuffer(sendBuffer int) *NanoBuilder
- func (sec *NanoBuilder) ToggleWriteDeadline(writeDeadline bool) *NanoBuilder
- func (sec *NanoBuilder) Websocket() *NanoBuilder
- func (sec NanoBuilder) WrapConnection(connection interface{}) (nan0 NanoServiceWrapper, err error)
- type NanoServer
- func (server *NanoServer) AddConnection(conn NanoServiceWrapper)
- func (server *NanoServer) GetAllConnections() []NanoServiceWrapper
- func (server *NanoServer) GetConnections() <-chan NanoServiceWrapper
- func (server NanoServer) GetHost() string
- func (server NanoServer) GetPort() int32
- func (server NanoServer) GetServiceName() string
- func (server NanoServer) GetServiceType() string
- func (server NanoServer) GetStartTime() int64
- func (server NanoServer) IsAlive() bool
- func (server NanoServer) IsExpired() bool
- func (server *NanoServer) IsShutdown() bool
- func (server *NanoServer) Shutdown()
- type NanoServiceWrapper
- type Server
- type Service
- func (*Service) Descriptor() ([]byte, []int)
- func (ns Service) Equals(other Service) bool
- func (m *Service) GetExpired() bool
- func (m *Service) GetHostName() string
- func (m *Service) GetPort() int32
- func (m *Service) GetServiceName() string
- func (m *Service) GetServiceType() string
- func (m *Service) GetStartTime() int64
- func (m *Service) GetUri() string
- func (ns Service) IsAlive() bool
- func (ns Service) IsExpired() bool
- func (ns *Service) NewNanoBuilder() *NanoBuilder
- func (*Service) ProtoMessage()
- func (ns *Service) Refresh()
- func (m *Service) Reset()
- func (ns *Service) Start() (net.Listener, error)
- func (m *Service) String() string
- func (m *Service) XXX_DiscardUnknown()
- func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Service) XXX_Merge(src proto.Message)
- func (m *Service) XXX_Size() int
- func (m *Service) XXX_Unmarshal(b []byte) error
- type WsNan0
Constants ¶
This section is empty.
Variables ¶
var ( Info = log.New(os.Stdout, "Nan0 [INFO]: ", log.Ldate|log.Ltime) Warn = log.New(os.Stderr, "Nan0 [WARN]: ", log.Ldate|log.Ltime) Error = log.New(os.Stderr, "Nan0 [ERROR]: ", log.Ldate|log.Ltime) Debug *log.Logger = nil )
Loggers provided:
Level | Output | Format Info: Standard Output - 'Nan0 [INFO] %date% %time%' Warn: Standard Error - 'Nan0 [DEBUG] %date% %time%' Error: Standard Error - 'Nan0 [ERROR] %date% %time%' Debug: Disabled by default
var MaxNanoCache = 50
The max queued connections for NanoServer handling, used with ListenTCP()
var ProtoPreamble = []byte{0x01, 0x02, 0x03, 0xFF, 0x03, 0x02, 0x01}
TCP Preamble, this pre-fixes a unique tcp transmission (protocol buffer message)
var SizeArrayWidth = defaultArrayWidth
The number of bytes that constitute the size of the proto.Message sent/received This variable is made visible so that developers can support larger data sizes
Converts the size header from the byte slice that represents it to an integer type NOTE: If you change SizeArrayWidth, you should also change this function This function is made visible so that developers can support larger data sizes
var SizeWriter = func(size int) (bytes []byte) { bytes = make([]byte, SizeArrayWidth) binary.BigEndian.PutUint32(bytes, uint32(size)) return bytes }
Converts the integer representing the size of the following protobuf message to a byte slice NOTE: If you change SizeReader, you should also change this function This function is made visible so that developers can support variable data sizes
var TCPTimeout = 10 * time.Second
The timeout for TCP Writers and server connections
Functions ¶
func SetLogWriter ¶
func ToggleLineNumberPrinting ¶
func ToggleLineNumberPrinting(info, warn, fail, debug bool)
Types ¶
type Nan0 ¶
type Nan0 struct { // The name of the service ServiceName string // contains filtered or unexported fields }
The Nan0 structure is a wrapper around a net/TCP connection which sends and receives protocol buffers across it. The protocol buffers are not descriptive and one must send or receive using the methods provided. If one needs more control over the conduit, one should create a connection to the server using the Server.DialTCP method.
func (*Nan0) Close ¶
func (n *Nan0) Close()
Closes the open connection and terminates the goroutines associated with reading them
func (Nan0) Equals ¶
func (n Nan0) Equals(other NanoServiceWrapper) bool
Determine if two instances are equal
func (Nan0) GetReceiver ¶
func (n Nan0) GetReceiver() <-chan interface{}
Returns a read-only channel that is used to receive a protocol buffer message returned through this connection
type NanoBuilder ¶
type NanoBuilder struct {
// contains filtered or unexported fields
}
func (*NanoBuilder) AddMessageIdentities ¶
func (sec *NanoBuilder) AddMessageIdentities(messageIdents ...proto.Message) *NanoBuilder
Adds multiple identity-type objects that will be cloned to either send or receive messages. All protocol buffers you intend to send or receive should be registered with this method or the transmissions will fail
func (*NanoBuilder) AddMessageIdentity ¶
func (sec *NanoBuilder) AddMessageIdentity(messageIdent proto.Message) *NanoBuilder
Adds a single identity-type object that will be cloned to either send or receive messages. All protocol buffers you intend to send or receive should be registered with this method or the transmissions will fail
func (NanoBuilder) Build ¶
func (sec NanoBuilder) Build() (nan0 NanoServiceWrapper, err error)
Establish a connection creating a first-class Nan0 connection which will communicate with the server
func (*NanoBuilder) BuildServer ¶
func (sec *NanoBuilder) BuildServer(handler func(net.Listener, *NanoBuilder)) (*NanoServer, error)
Build a wrapped server instance
func (*NanoBuilder) ReceiveBuffer ¶
func (sec *NanoBuilder) ReceiveBuffer(receiveBuffer int) *NanoBuilder
Part of the NanoBuilder chain, sets the number of messages that can be simultaneously placed on the receive buffer
func (*NanoBuilder) SendBuffer ¶
func (sec *NanoBuilder) SendBuffer(sendBuffer int) *NanoBuilder
Part of the NanoBuilder chain, sets the number of messages that can be simultaneously placed on the send buffer
func (*NanoBuilder) ToggleWriteDeadline ¶
func (sec *NanoBuilder) ToggleWriteDeadline(writeDeadline bool) *NanoBuilder
Part of the NanoBuilder chain, sets write deadline to the TCPTimeout global value
func (*NanoBuilder) Websocket ¶
func (sec *NanoBuilder) Websocket() *NanoBuilder
Enables websocket handling for this connection
func (NanoBuilder) WrapConnection ¶
func (sec NanoBuilder) WrapConnection(connection interface{}) (nan0 NanoServiceWrapper, err error)
Wrap a raw connection which will communicate with the server
type NanoServer ¶
type NanoServer struct {
// contains filtered or unexported fields
}
The NanoServer structure is a wrapper around a service which allows for the acceptance of connections which are wrapped automatically in Nan0 objects. This allows for the communication of protocol buffers along channels for each connection.
func (*NanoServer) AddConnection ¶
func (server *NanoServer) AddConnection(conn NanoServiceWrapper)
Puts a connection in the server
func (*NanoServer) GetAllConnections ¶
func (server *NanoServer) GetAllConnections() []NanoServiceWrapper
Get all connections that this service has ever opened
func (*NanoServer) GetConnections ¶
func (server *NanoServer) GetConnections() <-chan NanoServiceWrapper
Get the channel which is fed new connections to the server
func (NanoServer) GetHost ¶
func (server NanoServer) GetHost() string
Exposes the service delegate's hostName property
func (NanoServer) GetPort ¶
func (server NanoServer) GetPort() int32
Exposes the service delegate's port property
func (NanoServer) GetServiceName ¶
func (server NanoServer) GetServiceName() string
Exposes the service delegate's serviceName property
func (NanoServer) GetServiceType ¶
func (server NanoServer) GetServiceType() string
Exposes the service delegate's serviceType property
func (NanoServer) GetStartTime ¶
func (server NanoServer) GetStartTime() int64
Exposes the service delegate's startTime property
func (NanoServer) IsAlive ¶
func (server NanoServer) IsAlive() bool
Exposes the IsAlive method of the service delegate
func (NanoServer) IsExpired ¶
func (server NanoServer) IsExpired() bool
Exposes the IsExpired method of the service delegate
func (*NanoServer) IsShutdown ¶
func (server *NanoServer) IsShutdown() bool
func (*NanoServer) Shutdown ¶
func (server *NanoServer) Shutdown()
type NanoServiceWrapper ¶
type NanoServiceWrapper interface { // Close the wrapper goroutines and the underlying connections Close() // Check if the wrapper is closed IsClosed() bool // Return the sender channel for this nanoservice wrapper, messages are sent along this route GetSender() chan<- interface{} // Return the receiver channel for this nanoservice wrapper, messages are received from this GetReceiver() <-chan interface{} // Get the service name identifier GetServiceName() string // Determine if two instances are equal Equals(NanoServiceWrapper) bool // contains filtered or unexported methods }
Any object which wraps a connection to send and receive different protocol buffers
type Server ¶
type Server interface { IsAlive() bool IsExpired() bool IsShutdown() bool Shutdown() GetServiceName() string GetConnections() <-chan NanoServiceWrapper AddConnection(NanoServiceWrapper) }
Represents a server object with live-ness and registry to a discovery mechanism
type Service ¶
type Service struct { Expired bool `protobuf:"varint,1,opt,name=expired,proto3" json:"expired,omitempty"` Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` StartTime int64 `protobuf:"varint,3,opt,name=startTime,proto3" json:"startTime,omitempty"` HostName string `protobuf:"bytes,4,opt,name=hostName,proto3" json:"hostName,omitempty"` Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` ServiceName string `protobuf:"bytes,6,opt,name=serviceName,proto3" json:"serviceName,omitempty"` ServiceType string `protobuf:"bytes,7,opt,name=serviceType,proto3" json:"serviceType,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Service) Descriptor ¶
func (*Service) GetExpired ¶
func (*Service) GetHostName ¶
func (*Service) GetServiceName ¶
func (*Service) GetServiceType ¶
func (*Service) GetStartTime ¶
func (Service) IsExpired ¶
Checks if a particular nanoservice is expired based on its start time and time to live
func (*Service) NewNanoBuilder ¶
func (ns *Service) NewNanoBuilder() *NanoBuilder
func (*Service) ProtoMessage ¶
func (*Service) ProtoMessage()
func (*Service) Refresh ¶
func (ns *Service) Refresh()
Refreshes the start time so that this service does not expire
func (*Service) XXX_DiscardUnknown ¶
func (m *Service) XXX_DiscardUnknown()
func (*Service) XXX_Marshal ¶
func (*Service) XXX_Unmarshal ¶
type WsNan0 ¶
type WsNan0 struct { // The name of the service ServiceName string // contains filtered or unexported fields }
The WsNan0 structure is a wrapper around a websocket connection which sends and receives protocol buffers across it. Use the provided Builder object to correctly initialize this structure.
func (WsNan0) Close ¶
func (n WsNan0) Close()
Closes the open connection and terminates the goroutines associated with reading them
func (WsNan0) Equals ¶
func (n WsNan0) Equals(other NanoServiceWrapper) bool
Determine if two instances are equal
func (WsNan0) GetReceiver ¶
func (n WsNan0) GetReceiver() <-chan interface{}
Returns a read-only channel that is used to receive a protocol buffer message returned through this connection
func (WsNan0) GetSender ¶
func (n WsNan0) GetSender() chan<- interface{}
Return a write-only channel that is used to send a protocol buffer message through this connection
func (WsNan0) GetServiceName ¶
Get the service name identifier