Documentation ¶
Index ¶
- Constants
- type Client
- func (client *Client) AddListener(kind proto.PacketKind, listener func(in []byte) ([]byte, error))
- func (client *Client) Connect(ctx context.Context, connect chan bool) error
- func (client *Client) IsReady() bool
- func (client *Client) Pipe(pack Package)
- func (client *Client) PipeStatus(pack Package)
- func (client *Client) Recover()
- func (client *Client) Send(kind proto.PacketKind, in interface{}, out interface{}) error
- func (client *Client) StartWatchdog(ctx context.Context) error
- func (client *Client) Sync() error
- func (client *Client) WaitForConnection(timeout time.Duration) bool
- func (client *Client) WithBackoff(fn func() error)
- func (client *Client) WithBackoffLimit(fn func() error, limit int) error
- func (client *Client) Write(p []byte) (n int, err error)
- type DefaultPipeStore
- type Package
- type Pipe
- type PipeSender
- type PipeStore
- type PriorityQueue
Constants ¶
const ( ProtocolMajorVersion = 2 ProtocolMinorVersion = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { AccountID uuid.UUID ClusterID uuid.UUID ServerVersion string AgentPermissions string // contains filtered or unexported fields }
Client agent gateway client Client agent gateway client
func InitClient ¶
func InitClient( version string, startID string, accountID, clusterID uuid.UUID, secret []byte, serverVersion string, agentPermissions string, gatewayUrl string, protoHandshake time.Duration, protoWrite time.Duration, protoRead time.Duration, protoReconnect time.Duration, protoBackoff time.Duration, sendLogs bool, ) *Client
InitClient inits client
func (*Client) AddListener ¶
AddListener adds a listener for a specific packet kind
func (*Client) Pipe ¶
Pipe send packages to the agent-gateway with defined priorities and expiration rules
func (*Client) PipeStatus ¶
PipeStatus send status packages to the agent-gateway with defined priorities and expiration rules TODO remove
func (*Client) Recover ¶
func (client *Client) Recover()
Recover recover from panic used to send logs before exiting
func (*Client) Send ¶
func (client *Client) Send(kind proto.PacketKind, in interface{}, out interface{}) error
Send sends a packet to the agent-gateway if there is an established connection it internally uses client.send
func (*Client) WaitForConnection ¶
WaitForConnection waits for an established connection with the agent gateway it blocks until the agent gateway is connected and the agent is authenticated it takes a timeout parameter to return if not connected returns true if connected false if timeout occurred Example:
WaitForConnection(time.Second * 10)
func (*Client) WithBackoff ¶
func (*Client) WithBackoffLimit ¶
type DefaultPipeStore ¶
func NewDefaultPipeStore ¶
func NewDefaultPipeStore() *DefaultPipeStore
func (*DefaultPipeStore) Ack ¶
func (s *DefaultPipeStore) Ack(pack *Package)
func (*DefaultPipeStore) Add ¶
func (s *DefaultPipeStore) Add(pack *Package) int
func (*DefaultPipeStore) Len ¶
func (s *DefaultPipeStore) Len() int
func (*DefaultPipeStore) Peek ¶
func (s *DefaultPipeStore) Peek() *Package
func (*DefaultPipeStore) Pop ¶
func (s *DefaultPipeStore) Pop() *Package
type Package ¶
type Package struct { // Kind packet kind Kind proto.PacketKind // ExpiryTime time afterwards will not try to send packets // nil means never expires ExpiryTime *time.Time // ExpiryCount will expire if this number of packets come afterwards // 0 means never ExpiryCount int // Priority a number to indicate the order to send pending packets // the lower the value the more urget it is Priority int // Retries max number of retries before decreasing priority by one // 0 means never Retries int // Data data to be sent Data interface{} // contains filtered or unexported fields }
Package structure used to send packages over the channel
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
Pipe pipe
type PipeSender ¶
type PipeSender interface {
Send(kind proto.PacketKind, in interface{}, out interface{}) error
}
PipeSender interface for sender
type PipeStore ¶
type PipeStore interface { // Add adds a package to be sent, returns the number of dropped packages since the last add Add(*Package) int // Peek gets the first available package // returns the same if called multiple times without ack unless a package expires // returns nil if nothing in the queue Peek() *Package // Acks that a peeked package has been sent, does nothing if the package has expired Ack(*Package) // Pop is an atomic peek and ack // returns nil in case there are no packages Pop() *Package // Len gets the number of pending packets Len() int }
PipeStore store interface for packageges
type PriorityQueue ¶
type PriorityQueue []*Package
PriorityQueue implements heap.Interface and holds Items.
func (*PriorityQueue) First ¶
func (pq *PriorityQueue) First() interface{}
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)