mole

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2017 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FILE_UUID = "/etc/.mole.uuid"
)
View Source
var (
	HEADER = []byte("MOLE")
)

Functions

func Encode

func Encode(msg []byte) []byte

Types

type Agent

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

func NewAgent

func NewAgent(cfg *Config) *Agent

func (*Agent) Join

func (a *Agent) Join() error

func (*Agent) NewListener

func (a *Agent) NewListener() net.Listener

func (*Agent) ServeProtocol

func (a *Agent) ServeProtocol() error

type AgentListener

type AgentListener struct {
	sync.RWMutex // protect flag closed
	// contains filtered or unexported fields
}

func (*AgentListener) Accept

func (l *AgentListener) Accept() (net.Conn, error)

implement net.Listener interface the caller could process the cached worker connection in the pool via `AgentListener`

func (*AgentListener) Addr

func (l *AgentListener) Addr() net.Addr

func (*AgentListener) Close

func (l *AgentListener) Close() error

func (*AgentListener) HandleWorkerConn

func (l *AgentListener) HandleWorkerConn(conn net.Conn) error

implement ConnHandler interface put the worker connection to the pool

type ClusterAgent

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

ClusterAgent is a runtime agent object within master lifttime

func (*ClusterAgent) Client

func (ca *ClusterAgent) Client() *http.Client

Client obtain a http client for an agent with customized dialer

func (*ClusterAgent) Dial

func (ca *ClusterAgent) Dial(network, addr string) (net.Conn, error)

Dial specifies the dial function for creating unencrypted TCP connections within the http.Client

func (*ClusterAgent) ID

func (ca *ClusterAgent) ID() string

type Config

type Config struct {
	Role    Role     // both
	Listen  string   // master only
	Master  *url.URL // agent only
	Backend *url.URL // agent only
}

type ConnHandler

type ConnHandler interface {
	HandleWorkerConn(c net.Conn) error
}

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new protocol decoder that reads from r.

func (*Decoder) Buffered

func (d *Decoder) Buffered() []byte

func (*Decoder) Decode

func (d *Decoder) Decode() (*command, error)

Decode reads the next protocol-encoded command from reader Note that Decode() is not concurrency safe.

type Master

type Master struct {
	sync.RWMutex // protect agents map
	// contains filtered or unexported fields
}

func NewMaster

func NewMaster(l net.Listener) *Master

func (*Master) AddAgent

func (m *Master) AddAgent(id string, conn net.Conn)

func (*Master) Agent

func (m *Master) Agent(id string) *ClusterAgent

the caller should check the returned ClusterAgent is not nil otherwise the agent hasn't connected to the cluster

func (*Master) Agents

func (m *Master) Agents() map[string]*ClusterAgent

func (*Master) CloseAgent

func (m *Master) CloseAgent(id string)

func (*Master) CloseAllAgents

func (m *Master) CloseAllAgents()

func (*Master) FreshAgent

func (m *Master) FreshAgent(id string)

func (*Master) Serve

func (m *Master) Serve() error

type Role

type Role string
var (
	RoleMaster Role = "master"
	RoleAgent  Role = "agent"
)

Jump to

Keyboard shortcuts

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