server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// ctl name
	RetryCount string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(server *Server) Client

func (*Client) Clone

func (c *Client) Clone() *Client

func (*Client) GetResult

func (c *Client) GetResult(taskId string, timeout time.Duration, sleepTime time.Duration) (message.Result, error)

taskId: timeout: sleepDuration:

func (*Client) Send

func (c *Client) Send(groupName string, workerName string, args ...interface{}) (string, error)

return: taskId, err

func (*Client) SetTaskCtl

func (c *Client) SetTaskCtl(name string, value interface{}) *Client

type Server

type Server struct {
	sync.Map

	// config
	StatusExpires int // second, -1:forever
	ResultExpires int // second, -1:forever
	// contains filtered or unexported fields
}

func NewServer

func NewServer(c config.Config) Server

func (*Server) Add

func (t *Server) Add(groupName string, workerName string, w interface{})

add worker to group w : worker func

func (*Server) GetClient

func (t *Server) GetClient() Client

func (*Server) GetNextMessageGoroutine

func (t *Server) GetNextMessageGoroutine(groupName string)

get next message if worker is ready

func (*Server) GetQueryName

func (t *Server) GetQueryName(groupName string) string

func (*Server) GetResult

func (t *Server) GetResult(id string) (message.Result, error)

func (*Server) MakeWorkerReady

func (t *Server) MakeWorkerReady()

func (*Server) Next

func (t *Server) Next(groupName string) (message.Message, error)

func (*Server) Run

func (t *Server) Run(groupName string, numWorkers int)

func (*Server) Send

func (t *Server) Send(groupName string, workerName string, ctl controller.TaskCtl, args ...interface{}) (string, error)

send msg to queue t.Send("groupName", "workerName" , 1,"hi",1.2)

func (*Server) SetResult

func (t *Server) SetResult(result message.Result) error

func (*Server) Shutdown

func (t *Server) Shutdown(ctx context.Context) error

func (*Server) WorkerGoroutine

func (t *Server) WorkerGoroutine(groupName string)

start worker to run

Jump to

Keyboard shortcuts

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