rainbond: github.com/goodrain/rainbond/eventlog/util Index | Files

package util

import "github.com/goodrain/rainbond/eventlog/util"

Index

Package Files

buffer.go common.go conn.go file.go protocol.go streamserver.go

Variables

var (
    ErrConnClosing   = errors.New("use of closed network connection")
    ErrWriteBlocking = errors.New("write packet was blocking")
    ErrReadBlocking  = errors.New("read packet was blocking")
)

Error type

func AppendToFile Uses

func AppendToFile(fileName string, content string) error

AppendToFile 文件名字(带全路径) content: 写入的内容

func ExternalIP Uses

func ExternalIP() (net.IP, error)

ExternalIP 获取本机ip

func Format Uses

func Format(source map[string]gjson.Result) map[string]interface{}

Format 格式化处理监控数据

func GetHostID Uses

func GetHostID(nodeIDFile string) (string, error)

GetHostID 获取机器ID

func Source Uses

func Source(l *logrus.Entry) *logrus.Entry

type Buffer Uses

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

func NewBuffer Uses

func NewBuffer(source []byte) *Buffer

func (*Buffer) Bytes Uses

func (b *Buffer) Bytes() []byte

func (*Buffer) Cap Uses

func (b *Buffer) Cap() int

func (*Buffer) Grow Uses

func (b *Buffer) Grow(n int)

func (*Buffer) Len Uses

func (b *Buffer) Len() int

func (*Buffer) Next Uses

func (b *Buffer) Next(n int) []byte

func (*Buffer) Read Uses

func (b *Buffer) Read(p []byte) (n int, err error)

func (*Buffer) ReadByte Uses

func (b *Buffer) ReadByte() (c byte, err error)

func (*Buffer) ReadBytes Uses

func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)

func (*Buffer) ReadFrom Uses

func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)

func (*Buffer) ReadRune Uses

func (b *Buffer) ReadRune() (r rune, size int, err error)

func (*Buffer) ReadString Uses

func (b *Buffer) ReadString(delim byte) (line string, err error)

func (*Buffer) Reset Uses

func (b *Buffer) Reset()

func (*Buffer) String Uses

func (b *Buffer) String() string

func (*Buffer) Truncate Uses

func (b *Buffer) Truncate(n int)

func (*Buffer) UnreadByte Uses

func (b *Buffer) UnreadByte() error

func (*Buffer) UnreadRune Uses

func (b *Buffer) UnreadRune() error

func (*Buffer) Write Uses

func (b *Buffer) Write(p []byte) (n int, err error)

func (*Buffer) WriteByte Uses

func (b *Buffer) WriteByte(c byte) error

func (*Buffer) WriteRune Uses

func (b *Buffer) WriteRune(r rune) (n int, err error)

func (*Buffer) WriteString Uses

func (b *Buffer) WriteString(s string) (n int, err error)

func (*Buffer) WriteTo Uses

func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)

type Config Uses

type Config struct {
    PacketSendChanLimit    uint32 // the limit of packet send channel
    PacketReceiveChanLimit uint32 // the limit of packet receive channel
}

type Conn Uses

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

Conn exposes a set of callbacks for the various events that occur on a connection

func (*Conn) AsyncWritePacket Uses

func (c *Conn) AsyncWritePacket(p Packet, timeout time.Duration) (err error)

AsyncWritePacket async writes a packet, this method will never block

func (*Conn) Close Uses

func (c *Conn) Close()

Close closes the connection

func (*Conn) Do Uses

func (c *Conn) Do()

Do it

func (*Conn) GetExtraData Uses

func (c *Conn) GetExtraData() interface{}

GetExtraData gets the extra data from the Conn

func (*Conn) GetRawConn Uses

func (c *Conn) GetRawConn() *net.TCPConn

GetRawConn returns the raw net.TCPConn from the Conn

func (*Conn) IsClosed Uses

func (c *Conn) IsClosed() bool

IsClosed indicates whether or not the connection is closed

func (*Conn) PutExtraData Uses

func (c *Conn) PutExtraData(data interface{})

PutExtraData puts the extra data with the Conn

type ConnCallback Uses

type ConnCallback interface {
    // OnConnect is called when the connection was accepted,
    // If the return value of false is closed
    OnConnect(*Conn) bool

    // OnMessage is called when the connection receives a packet,
    // If the return value of false is closed
    OnMessage(Packet) bool

    // OnClose is called when the connection closed
    OnClose(*Conn)
}

ConnCallback is an interface of methods that are used as callbacks on a connection

type MessagePacket Uses

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

func (*MessagePacket) IsNull Uses

func (m *MessagePacket) IsNull() bool

func (*MessagePacket) IsPing Uses

func (m *MessagePacket) IsPing() bool

func (*MessagePacket) Serialize Uses

func (m *MessagePacket) Serialize() []byte

type MessageProtocol Uses

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

func (*MessageProtocol) Decode Uses

func (m *MessageProtocol) Decode() (string, error)

Decode 解码数据流

func (*MessageProtocol) ReadPacket Uses

func (m *MessageProtocol) ReadPacket() (Packet, error)

ReadPacket 获取消息流

func (*MessageProtocol) SetConn Uses

func (m *MessageProtocol) SetConn(conn *net.TCPConn)

type Packet Uses

type Packet interface {
    Serialize() []byte
    IsNull() bool
    IsPing() bool
}

type Protocol Uses

type Protocol interface {
    SetConn(conn *net.TCPConn)
    ReadPacket() (Packet, error)
}

type Server Uses

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

func NewServer Uses

func NewServer(config *Config, callback ConnCallback, ctx context.Context) *Server

NewServer creates a server

func (*Server) Start Uses

func (s *Server) Start(listener *net.TCPListener, acceptTimeout time.Duration)

Start starts service

func (*Server) Stop Uses

func (s *Server) Stop()

Stop stops service

Package util imports 18 packages (graph) and is imported by 3 packages. Updated 2018-04-24. Refresh now. Tools for package owners.