gselib

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EINVAL int = iota
	ErrNetClosing
	ErrIOTimeout
	EPIPE
)
View Source
const (
	GSE_TYPE_COMMON   = 3072 + 1  // MSG_DATA_REPORT
	GSE_TYPE_GET_CONF = 0x0A      // REPORT_SYNC_CONFIG
	GSE_TYPE_DYNAMIC  = 0x09      // REPORT_DYNAMICAL_PROTOCOL_TYPE
	GSE_TYPE_OP       = 3072 + 12 // MSG_DATA_REPORT_OPS
	GSE_TYPE_TLOGC    = 0x02      // REPORT_EXT
)

gse protocol type

View Source
const (
	GSE_TYPE_DYNAMIC_DEFAULT_META_MAX_LEN = 408 // keep same with gse (8 + 128) * 3 = 408b
	GSE_TYPE_DYNAMIC_EXT_HEAD_LEN         = 24  // sizeof (index ... metaCount) = 24B
	GSE_TYPE_DYNAMIC_META_LEN             = 8   // len(keyLen) + len(valueLen) = 8B
)
View Source
const (
	BYTE = 1.0 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
)
View Source
const (
	GSE_FLAG_REDUNDENCY = 0x01 // PLUGIN_REDUNDENCY_FLAG
)

gse protocol flags

View Source
const MockAddress = "/tmp/ipc.state.report"
View Source
const MockNetwork = "unix"

Variables

This section is empty.

Functions

func StartMockAgent

func StartMockAgent()

Types

type AgentInfo

type AgentInfo struct {
	Bizid    int32
	Cloudid  int32
	IP       string
	Hostname string
}

AgentInfo : get info from agent now can get bizid, cloudid, ip

func (*AgentInfo) String

func (info *AgentInfo) String() string

String

type Config

type Config struct {
	ReconnectTimes uint          `config:"reconnecttimes"`
	RetryTimes     uint          `config:"retrytimes"`
	RetryInterval  time.Duration `config:"retryinterval"`
	MsgQueueSize   uint          `config:"mqsize"`
	WriteTimeout   time.Duration `config:"writetimeout"`
	Endpoint       string        `config:"endpoint"`
	Nonblock       bool          `config:"nonblock"` // TODO not used now
}

Config GseClient config

type GseClient

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

GseClient : gse client used for send data and get agent info

func NewGseClient

func NewGseClient(cfg *common.Config) (*GseClient, error)

NewGseClient create a gse client host set to default gse ipc path, different from linux and windows

func NewGseClientFromConfig

func NewGseClientFromConfig(c Config) (*GseClient, error)

func (*GseClient) Close

func (c *GseClient) Close()

Close : release resources

func (*GseClient) GetAgentInfo

func (c *GseClient) GetAgentInfo() (AgentInfo, error)

GetAgentInfo : get agent info client will update info from gse agent every 1min request from agent first time when client start

func (*GseClient) Send

func (c *GseClient) Send(msg GseMsg) error

Send : send msg to client will bolck when queue is full

func (*GseClient) SendWithNewConnection

func (c *GseClient) SendWithNewConnection(msg GseMsg) error

SendWithNewConnection : send msg to client with new connection every time

func (*GseClient) Start

func (c *GseClient) Start() error

Start : start client start to recv msg and get agent info run as goroutine

type GseCommonMsg

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

GseCommonMsg : msg for GSE_TYPE_COMMON

func NewGseCommonMsg

func NewGseCommonMsg(data []byte, dataid int32, resv1, resv2, flag uint32) *GseCommonMsg

NewGseCommonMsg

func (*GseCommonMsg) ToBytes

func (msg *GseCommonMsg) ToBytes() []byte

ToBytes

type GseCommonMsgHead

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

GseCommonMsgHead

type GseConnection

type GseConnection interface {
	Dial() error
	Close() error
	Write(b []byte) (int, error)
	SetWriteTimeout(t time.Duration)
	Read(b []byte) (int, error)
	SetHost(host string)
}

GseConnection : gse connection

type GseDynamicMetaInfo

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

GseDynamicMetaInfo

type GseDynamicMsg

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

GseDynamicMsg :

func NewGseDynamicMsg

func NewGseDynamicMsg(data []byte, dataid int32, resv1, resv2 uint32) *GseDynamicMsg

NewGseDynamicMsg : new GseDynamicMsg

func (*GseDynamicMsg) AddMeta

func (msg *GseDynamicMsg) AddMeta(key, value string) error

AddMeta

func (*GseDynamicMsg) ToBytes

func (msg *GseDynamicMsg) ToBytes() []byte

ToBytes : change msg to bytes

type GseDynamicMsgHead

type GseDynamicMsgHead struct {
	GseCommonMsgHead
	// contains filtered or unexported fields
}

GseDynamicMsgHead

type GseLinuxConnection

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

GseLinuxConnection : gse socket struct on Linux

func NewGseConnection

func NewGseConnection() *GseLinuxConnection

NewGseConnection : create a gse client host set to default gse ipc path, different from linux and windows

func (*GseLinuxConnection) Close

func (c *GseLinuxConnection) Close() error

Close : release resources

func (*GseLinuxConnection) Dial

func (c *GseLinuxConnection) Dial() error

Dial : connect to gse agent

func (*GseLinuxConnection) Read

func (c *GseLinuxConnection) Read(b []byte) (int, error)

func (*GseLinuxConnection) SetHost

func (c *GseLinuxConnection) SetHost(host string)

SetHost : set agent host

func (*GseLinuxConnection) SetWriteTimeout

func (c *GseLinuxConnection) SetWriteTimeout(t time.Duration)

func (*GseLinuxConnection) Write

func (c *GseLinuxConnection) Write(b []byte) (int, error)

type GseLocalCommandMsg

type GseLocalCommandMsg struct {
	MsgType uint32
	BodyLen uint32
}

GseLocalCommandMsg

type GseMsg

type GseMsg interface {
	ToBytes() []byte
}

GseMsg : gse msg

type GseOpMsg

type GseOpMsg struct {
	GseCommonMsg
}

GseOpMsg : msg for MSG_DATA_REPORT_OPS

func NewGseOpMsg

func NewGseOpMsg(data []byte, dataid int32, resv1, resv2, flag uint32) *GseOpMsg

NewGseOpMsg

type GseRequestConfMsg

type GseRequestConfMsg struct {
	GseCommonMsg
}

GseRequestConfMsg : msg for GSE_TYPE_GET_CONF

func NewGseRequestConfMsg

func NewGseRequestConfMsg() *GseRequestConfMsg

NewGseRequestConfMsg

type GseSimpleClient

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

GseSimpleClient : gse client used for send data and get agent info

func NewGseSimpleClient

func NewGseSimpleClient() *GseSimpleClient

NewGseSimpleClient create a gse client host set to default gse ipc path, different from linux and windows

func (*GseSimpleClient) Close

func (c *GseSimpleClient) Close()

Close : release resources

func (*GseSimpleClient) GetAgentInfo

func (c *GseSimpleClient) GetAgentInfo() (AgentInfo, error)

GetAgentInfo : get agent info client will update info from gse agent every 1min request from agent first time when client start

func (*GseSimpleClient) Send

func (c *GseSimpleClient) Send(msg GseMsg) error

Send : send msg to client will bolck when queue is full

func (*GseSimpleClient) SetAgentHost

func (c *GseSimpleClient) SetAgentHost(host string)

SetAgentHost : set agent host

func (*GseSimpleClient) Start

func (c *GseSimpleClient) Start() error

Start : start client start to recv msg and get agent info run as goroutine

func (*GseSimpleClient) SyncGetAgentInfo

func (c *GseSimpleClient) SyncGetAgentInfo() (AgentInfo, error)

SyncGetAgentInfo : sync request agent info

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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