Documentation ¶
Overview ¶
JDI. A worker that does the job
Index ¶
- Variables
- func AddTasksOfAnotherWorker(worker string, tasks []string)
- func Connect() (err error)
- func CreateLogger() *zap.Logger
- func CreateRouter()
- func GetTask(name string) job.JobFunc
- func GinAPI()
- func GracefulShutdown()
- func Healthy() (bool, map[string]string)
- func Init() (err error)
- func MessageReceived(m *Message)
- func PublishExecutingTasks()
- func RandString(length int) string
- func RegisteredTasksList() []string
- func StartAllQueues()
- func StopAPI()
- func StopWorker()
- func StringWithCharset(length int, charset string) string
- func TasksInCluster() []string
- func WaitToFinish()
- type Job
- type JobID
- type Message
- type MessageBroker
- type MessageBrokerNATS
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Router *gin.Engine Port int )
View Source
var ( // default: "jdi-chan-task" TaskChannel string TasksBrokerURI string TasksStorage string )
View Source
var ( // If Debug == true some changes are made: // // 1. Logger is created in "debug" mode DEBUG bool MessageChannel string // If Monitor = true - no tasks will be executed by this instance. Monitor bool = false MessagesBroker string = "nats://localhost" // A list of other workers' tasks that I don't have in RegisteredTasks // A map of { task-name: map-of-workers-having-that-task } // Why map of workers? To have a unique list of them without duplicates. OtherWorkersTasks map[string]map[string]struct{} OtherWorkers map[string]struct{} ACKS_LATE bool )
View Source
var Delay func(taskName string, args ...interface{}) string
This can be set only after task broker initialization
View Source
var (
Exit chan bool
)
View Source
var (
IsHealthy bool
)
View Source
var RegisterTask = task.RegisterTask
var Delay = task.Broker.Delay
Functions ¶
func AddTasksOfAnotherWorker ¶
func CreateLogger ¶
func CreateRouter ¶
func CreateRouter()
func GracefulShutdown ¶
func GracefulShutdown()
func Healthy ¶
This function is called either once in 10 seconds or when hitting /healthcheck route.
func MessageReceived ¶
func MessageReceived(m *Message)
MessageReceived handles messages from other JDI workers
Possible messages:
newbie-here When a new worker starts - it send this message
func PublishExecutingTasks ¶
func PublishExecutingTasks()
// Sends executing tasks list to "tasks" channel
func RandString ¶
func RegisteredTasksList ¶
func RegisteredTasksList() []string
RegisteredTasksList returns a slice of registered Task names.
func StartAllQueues ¶
func StartAllQueues()
func StringWithCharset ¶
func TasksInCluster ¶
func TasksInCluster() []string
Types ¶
type MessageBroker ¶
type MessageBroker interface { // Init connects to a message broker and subscribes. Init(uri string) error // Send a message to all workers including myself. // Usually it's enough to specify only cmd. // But if a command needs arguments - pass them in args Send(cmd string, args interface{}) error }
var Msg MessageBroker
type MessageBrokerNATS ¶
type MessageBrokerNATS struct { Conn *nats.Conn // core NATS // contains filtered or unexported fields }
func (*MessageBrokerNATS) Init ¶
func (b *MessageBrokerNATS) Init(uri string) (err error)
func (*MessageBrokerNATS) Send ¶
func (b *MessageBrokerNATS) Send(cmd string, m interface{}) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.