basereporter

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinReportInterval = 1 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientStream

type ClientStream struct {
	ConnectFunc CreateClientStreamFunc

	Stream CloseAbleStream

	IPString string
	// contains filtered or unexported fields
}

一个与monitor连接的stream,用于发送和接收某种统计数据

func (*ClientStream) CreateStream

func (cs *ClientStream) CreateStream(conn *network.Connection) error

创建一个clientStream

func (*ClientStream) DestroyStream

func (cs *ClientStream) DestroyStream() error

关闭clientStream

type CloseAbleStream

type CloseAbleStream interface {
	CloseSend() error
}

type CreateClientStreamFunc

type CreateClientStreamFunc func(conn monitorpb.GrpcAPIClient) (client CloseAbleStream,
	cancelFunc context.CancelFunc, err error)

根据与monitor的连接创建clientStream

type Reporter

type Reporter struct {
	*plugin.PluginBase
	*common.RunContext
	SDKToken      model.SDKToken
	ClientStreams []*ClientStream
	ConnManager   network.ConnectionManager

	// 插件工厂
	Plugins plugin.Supplier
	// 本地缓存插件
	Registry localregistry.LocalRegistry
}

连接monitor的reporter的基类,具备一些大多数reporter需要的字段和连接管理方法

func InitBaseReporter

func InitBaseReporter(ctx *plugin.InitContext, streamFunc []CreateClientStreamFunc) (*Reporter, error)

获取一个baseReporter

func (*Reporter) CreateStreamWithIndex

func (s *Reporter) CreateStreamWithIndex(idx int) error

连接monitor,并且创建对应的clientStream

func (*Reporter) DestroyStreamWithIndex

func (s *Reporter) DestroyStreamWithIndex(idx int) error

断开与monitor的连接并且销毁所有clientStream

func (*Reporter) GetClientStream

func (s *Reporter) GetClientStream(idx int) CloseAbleStream

获取对应的clientStream用于发送和接收数据

func (*Reporter) GetClientStreamServer

func (s *Reporter) GetClientStreamServer(idx int) network.ConnID

func (*Reporter) GetIPString

func (s *Reporter) GetIPString() string

获取客户端的ip地址

func (*Reporter) GetMonitorConnection

func (s *Reporter) GetMonitorConnection() (*network.Connection, error)

获取一个与monitor的连接

func (*Reporter) ReleaseMonitorConnection

func (s *Reporter) ReleaseMonitorConnection(conn *network.Connection)

释放一个与monitor的连接

Jump to

Keyboard shortcuts

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