Documentation
¶
Index ¶
- Constants
- Variables
- func Data2Packet(data []byte) []byte
- func Data2Stream(data []byte, conn io.Writer) (int, error)
- func FillDefaultPort(addr string, port int) string
- func Get(addr string, key string, timeout time.Duration) (value string, err error)
- func Packet2Data(packet []byte) (data []byte, err error)
- func RunAgent(addr string, callback func(string) (string, error)) error
- func RunTrapper(addr string, callback func(TrapperRequest) (TrapperResponse, error)) error
- func Stream2Data(conn io.Reader) (rdata []byte, err error)
- type TrapperData
- type TrapperRequest
- type TrapperResponse
Constants ¶
View Source
const ( AgentDefaultPort = 10050 ServerDefaultPort = 10051 )
View Source
const ( HeaderString = "ZBXD" HeaderLength = len(HeaderString) HeaderVersion = uint8(1) DataLengthOffset = int64(HeaderLength + 1) DataLengthSize = int64(8) DataOffset = int64(DataLengthOffset + DataLengthSize) ErrorMessage = "ZBX_NOTSUPPORTED" )
View Source
const ( TrapperResponseSuccess = "success" TrapperResponseInfoFmt = "processed: %d; failed: %d; total: %d; seconds spent: %f" TrapperRequestString = "sender data" )
Variables ¶
View Source
var ( ErrorMessageBytes = []byte(ErrorMessage) Terminator = []byte("\n") HeaderBytes = []byte(HeaderString) )
Functions ¶
func Data2Packet ¶
func FillDefaultPort ¶
func Packet2Data ¶
func RunTrapper ¶ added in v0.0.6
func RunTrapper(addr string, callback func(TrapperRequest) (TrapperResponse, error)) error
Types ¶
type TrapperData ¶ added in v0.0.6
type TrapperRequest ¶ added in v0.0.6
type TrapperRequest struct {
Request string `json:"request"`
Clock int64 `json:"clock"`
Data []TrapperData `json:"data"`
}
func (TrapperRequest) ToPacket ¶ added in v0.0.6
func (r TrapperRequest) ToPacket() []byte
type TrapperResponse ¶ added in v0.0.6
type TrapperResponse struct {
Response string `json:"response"`
Info string `json:"info"`
Proceeded int `json:""`
Failed int `json:""`
Total int `json:""`
}
func Send ¶ added in v0.0.6
func Send(addr string, data TrapperData, timeout time.Duration) (TrapperResponse, error)
func SendBulk ¶ added in v0.0.6
func SendBulk(addr string, req TrapperRequest, timeout time.Duration) (res TrapperResponse, err error)
func (TrapperResponse) ToPacket ¶ added in v0.0.6
func (r TrapperResponse) ToPacket() []byte
Click to show internal directories.
Click to hide internal directories.