commands

package
v0.0.0-...-8c44216 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdMap = []CmdDefinition{
	{
		Name:        "AUTH",
		Handler:     Auth,
		RequireAuth: false,
		UseGroup:    false,
		Args:        2,
		Usage:       "AUTH {username} {password}",
		Description: "Authenticate with a username and a password",
	}, {
		Name:        "USE_GROUP",
		Handler:     UseGroup,
		RequireAuth: true,
		UseGroup:    false,
		Args:        1,
		Usage:       "USE_GROUP {group}",
		Description: "Declare which group the client want to use",
	}, {
		Name:        "PUBLISH",
		Handler:     Publish,
		RequireAuth: true,
		UseGroup:    true,
		Args:        3,
		Usage:       "PUBLISH {queue_slug} {job_type} {job_payload}",
		Description: "Create a job in a queue and return the ID of the created job",
	}, {
		Name:        "SUBSCRIBE",
		Handler:     Subscribe,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "SUBSCRIBE {queue_slug}",
		Description: "Subscribe to a queue to receive jobs",
	}, {
		Name:        "UNSUBSCRIBE",
		Handler:     Unsubscribe,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "UNSUBSCRIBE {queue_slug}",
		Description: "The exact oposite of the SUBSCRIBE command",
	}, {
		Name:        "LIST_QUEUES",
		Handler:     ListQueues,
		RequireAuth: true,
		UseGroup:    true,
		Description: "List all queues in the current group",
	}, {
		Name:        "DELETE_QUEUE",
		Handler:     DeleteQueue,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "DELETE_QUEUE {queue_slug}",
		Description: "Delete a queue",
	}, {
		Name:        "PURGE_JOBS",
		Handler:     PurgeJobs,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "PURGE_JOBS {queue_slug}",
		Description: "Delete every jobs in a queue",
	}, {
		Name:        "PURGE_WORKERS",
		Handler:     PurgeWorkers,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "PURGE_WORKERS {queue_slug}",
		Description: "Unsubscribe every worker in a queue",
	}, {
		Name:        "LIST_JOBS",
		Handler:     ListJobs,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "LIST_JOBS {queue_slug}",
		Description: "List all jobs in a queue",
	}, {
		Name:        "UPDATE_JOB",
		Handler:     UpdateJob,
		RequireAuth: true,
		UseGroup:    true,
		Args:        2,
		Usage:       "UPDATE_JOB {job_id} {job_status}",
		Description: "Set the status of a job",
	}, {
		Name:        "DELETE_JOB",
		Handler:     DeleteJob,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "DELETE_JOB {job_id}",
		Description: "Delete a job",
	}, {
		Name:        "DISPATCH",
		Handler:     Dispatch,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Will force the dispatch of jobs accross all the workers",
	}, {
		Name:        "RECURRENT_JOB",
		Handler:     DeclareRecurrentJob,
		RequireAuth: true,
		UseGroup:    true,
		Args:        3,
		Usage:       "RECURRENT_JOB {queue_slug} {job_type} {cron_instruction}",
		Description: "Declare recurrent job on a queue",
	}, {
		Name:        "LIST_RECURRENT_JOBS",
		Handler:     ListRecurrentJobs,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "LIST_RECURRENT_JOBS {queue_slug}",
		Description: "List all the recurrent jobs of a queue",
	}, {
		Name:        "DELETE_RECURRENT_JOB",
		Handler:     DeleteRecurrentJobs,
		RequireAuth: true,
		UseGroup:    true,
		Args:        1,
		Usage:       "DELETE_RECURRENT_JOB {job_entry_id}",
		Description: "Delete a recurrent job",
	}, {
		Name:        "HEALTH",
		Handler:     Health,
		RequireAuth: true,
		UseGroup:    false,
		Description: "Get the health of this jobatator instance",
	}, {
		Name:        "DEBUG_PARTS",
		Handler:     DebugParts,
		RequireAuth: false,
		UseGroup:    false,
		Args:        -1,
		Description: "Dump parsed command parts",
	}, {
		Name:        "DEBUG",
		Handler:     Debug,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Dump server data in a human readable format, only work if debug is enabled",
	}, {
		Name:        "DEBUG_JSON",
		Handler:     DebugJSON,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Dump server data in a JSON format, only work if debug is enabled",
	}, {
		Name:        "STOP_SERVER",
		Handler:     StopServer,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Stop the server, only work if test_mode is enabled",
	}, {
		Name:        "PING",
		Handler:     Ping,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Check if the connexion is alive",
	}, {
		Name:        "QUIT",
		Handler:     Quit,
		RequireAuth: false,
		UseGroup:    false,
		Description: "Disconnect from the server",
	}, {
		Name:        "CURRENT_SESSION",
		Handler:     CurrentSession,
		RequireAuth: true,
		UseGroup:    false,
		Description: "Get current session data (user allowed groups for example)",
	}, {
		Name:        "LIST_SESSIONS",
		Handler:     ListSessions,
		RequireAuth: true,
		UseGroup:    false,
		Description: "List all sessions in the group",
	},
}

CmdMap -

Functions

func Auth

func Auth(cmd CmdInterface)

Auth -

func CurrentSession

func CurrentSession(cmd CmdInterface)

CurrentSession - Get current session meta data

func Debug

func Debug(cmd CmdInterface)

Debug -

func DebugJSON

func DebugJSON(cmd CmdInterface)

DebugJSON -

func DebugParts

func DebugParts(cmd CmdInterface)

DebugParts -

func DeclareRecurrentJob

func DeclareRecurrentJob(cmd CmdInterface)

DeclareRecurrentJob -

func DeleteJob

func DeleteJob(cmd CmdInterface)

DeleteJob - Delete a job

func DeleteQueue

func DeleteQueue(cmd CmdInterface)

DeleteQueue - Delete a queue

func DeleteRecurrentJobs

func DeleteRecurrentJobs(cmd CmdInterface)

DeleteRecurrentJobs - Delete a recurrent job with a entry id in a queue

func Dispatch

func Dispatch(cmd CmdInterface)

Dispatch -

func DispatchUniversal

func DispatchUniversal()

DispatchUniversal -

func DispatchUniversalWithDelay

func DispatchUniversalWithDelay(delay int)

DispatchUniversalWithDelay -

func Health

func Health(cmd CmdInterface)

Health - Get all kinds of data about the jobatator instance

func Help

func Help(cmd CmdInterface)

Help - List all commands or get help about a specific command

func ListJobs

func ListJobs(cmd CmdInterface)

ListJobs - List all jobs in a queue

func ListQueues

func ListQueues(cmd CmdInterface)

ListQueues - List all the queues in a group

func ListRecurrentJobs

func ListRecurrentJobs(cmd CmdInterface)

ListRecurrentJobs - List all recurrent jobs in a queue

func ListSessions

func ListSessions(cmd CmdInterface)

ListSessions - List all sessions in the current group

func NewLine

func NewLine(cmd CmdInterface)

NewLine -

func Ping

func Ping(cmd CmdInterface)

Ping -

func ProcessRecurrentJob

func ProcessRecurrentJob(cmd CmdInterface)

ProcessRecurrentJob -

func Publish

func Publish(cmd CmdInterface)

Publish - Cli interface

func PublishUniversal

func PublishUniversal(parts map[int]string, user store.User) (string, error)

PublishUniversal - Will add a job on a queue PUBLISH queue_name job_type payload

func PurgeJobs

func PurgeJobs(cmd CmdInterface)

PurgeJobs - Will delete every jobs in a queue

func PurgeWorkers

func PurgeWorkers(cmd CmdInterface)

PurgeWorkers - Will delete every worker in a queue (so unsubscribe all the worker from a particular queue)

func Quit

func Quit(cmd CmdInterface)

Quit -

func ReturnError

func ReturnError(cmd CmdInterface, err string)

ReturnError -

func ReturnString

func ReturnString(cmd CmdInterface, data string)

ReturnString -

func StopServer

func StopServer(cmd CmdInterface)

StopServer - Will exit the server process, only work if TEST_MODE env var or config key 'test_mode' is set to true

Warning: this feature is really dangerous and open serious security risks. Use it with cares.

func Subscribe

func Subscribe(cmd CmdInterface)

Subscribe - If the client is a worker, he will use this cmd to subscribe to a queue

func Unsubscribe

func Unsubscribe(cmd CmdInterface)

Unsubscribe - If the client is a worker, he will use this cmd to unsubscribe from a queue

func UpdateJob

func UpdateJob(cmd CmdInterface)

UpdateJob - Update the state of the job Arguments: JOB_ID, JOB_STATUS

func UseGroup

func UseGroup(cmd CmdInterface)

UseGroup - will switch the session on a specific group

func UseGroupUniversal

func UseGroupUniversal(groupRaw string, user store.User) (store.Group, error)

UseGroupUniversal -

Types

type CmdDefinition

type CmdDefinition struct {
	Name        string
	RequireAuth bool
	UseGroup    bool
	Args        int
	Description string
	Usage       string
	Handler     func(CmdInterface)
}

CmdDefinition - Use to define the command

type CmdInterface

type CmdInterface struct {
	Parts map[int]string
	Conn  net.Conn
	User  store.User
}

CmdInterface - Passed to command handler

type DebugOutput

type DebugOutput struct {
	Queues   []store.Queue
	Groups   []store.Group
	Sessions []store.User
	Users    []store.User
	Host     string
	Port     int
}

DebugOutput -

type DispatchData

type DispatchData struct {
	Job   store.Job
	Debug string
}

DispatchData -

type HealthOutput

type HealthOutput struct {
	Uptime        int64
	Os            string
	Version       string
	NumCPU        int
	NumGoroutine  int
	NumSessions   int
	NumAuthed     int
	NumGroups     int
	NumUsers      int
	NumQueues     int
	NumJobs       int
	NumWorkers    int
	UnixTimestamp int64
}

HealthOutput -

type SessionOutput

type SessionOutput struct {
	Username     string
	Addr         string
	CurrentGroup string
	IsWorker     bool
	Groups       []string
}

SessionOutput - Represent the current session

Jump to

Keyboard shortcuts

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