server_register

package module
v0.0.0-...-90f907d Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 24 Imported by: 0

README

server-register

this is a study demo learn for service - found & load balenced

Documentation

Index

Constants

View Source
const (
	ErrHostnameEmpty   = "error: node's hostname is empty"
	ErrTaskIdNoExisted = "error: task_id was not existed"
)
View Source
const CommandTimeout = 15
View Source
const CommandTimeoutEnv = "DATE_AGENT_CMD_TIMEOUT"
View Source
const DefaultEtcdUri = "127.0.0.1:2379"

Variables

This section is empty.

Functions

func Exec

func Exec(suffix []string) (out string, err error)

func GetHostName

func GetHostName() (string, error)

GetHostName : get the hostname of host machine

Types

type Client

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

func NewClient

func NewClient(addr string) (*Client, error)

NewClient returns the pointer of the Client structure

func (*Client) Close

func (c *Client) Close()

func (*Client) DoneSignal

func (c *Client) DoneSignal() <-chan struct{}

type Hub

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

func NewHub

func NewHub(max int) *Hub

func (*Hub) CompleteTask

func (h *Hub) CompleteTask(hostname string, taskId int32, output string) error

func (*Hub) NewTask

func (h *Hub) NewTask(commands []string)

func (*Hub) PullTask

func (h *Hub) PullTask(hostname string) *Task

func (*Hub) Register

func (h *Hub) Register(hostname string) error

type Node

type Node struct {
	Hostname string     `json:"hostname"`
	Status   NodeStatus `json:"status"`
	Time     time.Time  `json:"time"`
}

func NewNode

func NewNode(hostname string) *Node

type NodeStatus

type NodeStatus int32
const (
	NodeOnline  NodeStatus = iota
	NodeOffline NodeStatus = 1
	NodeRemoved NodeStatus = 2
)

type Return

type Return struct {
	TaskId int32  `json:"task_id"`
	Output string `json:"output"`
}

type Server

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

func NewServer

func NewServer(grpcAddr string) *Server

func (*Server) CompleteTask

func (*Server) CrontabUpdate

func (s *Server) CrontabUpdate()

func (*Server) NewTask

func (s *Server) NewTask(commands []string)

func (*Server) PullTask

func (s *Server) PullTask(ctx context.Context, req *proto.PullTaskRequest) (*proto.PullTaskReply, error)

func (*Server) Register

func (s *Server) Register(ctx context.Context, req *proto.RegisterRequest) (*proto.RegisterReply, error)

type Task

type Task struct {
	Id      int32             `json:"id"`
	Command []string          `json:"command"`
	Result  map[string]string `json:"result"`
}

Directories

Path Synopsis
etcd
example

Jump to

Keyboard shortcuts

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