pool

package
v0.0.0-...-ecc5721 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Command *pb.Command
	Error   error
	Ready   chan bool
}

type Config

type Config struct {
	PoolLength        int
	ChanLen           int
	CommSendTimeOut   time.Duration
	CommResultTimeOut time.Duration
	TaskTimeWeight    time.Duration
	TaskCountWeight   int
	Interval          time.Duration
}

func NewConfig

func NewConfig() *Config

type Connection

type Connection struct {
	Ctx       context.Context    `json:"-"`
	CancelFuc context.CancelFunc `json:"-"`

	//use to post commands to the agent, if the *Command is nil, close the connection.
	//otherwise, send the command to the agent.
	CommandChan chan *Command `json:"-"`

	AgentID    string `json:"agent_id"`
	SourceAddr string `json:"addr"`
	CreateAt   int64  `json:"create_at"`
	// contains filtered or unexported fields
}

Connection Info

func (*Connection) GetAgentDetail

func (c *Connection) GetAgentDetail() map[string]interface{}

func (*Connection) GetPluginDetail

func (c *Connection) GetPluginDetail(name string) map[string]interface{}

func (*Connection) GetPluginsList

func (c *Connection) GetPluginsList() []map[string]interface{}

func (*Connection) SetAgentDetail

func (c *Connection) SetAgentDetail(detail map[string]interface{})

func (*Connection) SetPluginDetail

func (c *Connection) SetPluginDetail(name string, detail map[string]interface{})

type GRPCPool

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

func NewGRPCPool

func NewGRPCPool(config *Config) *GRPCPool

NewGRPCPool create a new GRPCPool. -- maxConnTokenCount: Maximum number of concurrent connections

func (*GRPCPool) Add

func (g *GRPCPool) Add(agentID string, conn *Connection) error

return error if AgentID conflict.

func (*GRPCPool) Close

func (g *GRPCPool) Close(agentID string) (err error)

Close send nil conn to close the agent

func (*GRPCPool) Delete

func (g *GRPCPool) Delete(agentID string)

Delete

func (*GRPCPool) GetByID

func (g *GRPCPool) GetByID(agentID string) (*Connection, error)

GetByAgentID

func (*GRPCPool) GetCount

func (g *GRPCPool) GetCount() int

GetConnectionCount

func (*GRPCPool) GetExtraInfoByID

func (g *GRPCPool) GetExtraInfoByID(agentID string) *client.AgentExtraInfo

func (*GRPCPool) GetList

func (g *GRPCPool) GetList() []*Connection

get List

func (*GRPCPool) LoadToken

func (g *GRPCPool) LoadToken() bool

LoadToken

Returns true when the current total number of connection < the length of the pool.

func (*GRPCPool) PostCommand

func (g *GRPCPool) PostCommand(agentID string, command *pb.Command) (err error)

PostCommand Post command to agent

func (*GRPCPool) PostLatestConfig

func (g *GRPCPool) PostLatestConfig(agentID string) error

Post the latest configuration to agent

func (*GRPCPool) PushTask2Manager

func (g *GRPCPool) PushTask2Manager(task map[string]string) error

PushTask2Manager push task to the remote end for reconciliation asynchronously.

func (*GRPCPool) ReleaseToken

func (g *GRPCPool) ReleaseToken()

ReleaseToken release the connection token to the pool; must be called after the conn is closed.

Jump to

Keyboard shortcuts

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