Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ErrorJobHasExpired : Requested job has expired and scheduler won't run it ErrorJobHasExpired = "Job has expired" // ErrorNewConnection : Error occured during net.Listen for new TCP connection ErrorNewConnection = "Failed to open TCP connection" // ErrorClosedConnection : Error occured because the connection is already closed ErrorClosedConnection = "Using closed connection" // ErrorInvalidChannelName : A valid channel name must contain alphabets, numbers, or underscore ErrorInvalidChannelName = "Invalid channel name" // ErrorInvalidJobID : A valid channel name must contain alphabets or numbers ErrorInvalidJobID = "Invalid Job ID" )
View Source
const ( JobStatusInactive = 0 JobStatusActive = 1 )
All job statuses
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { AddJob(channel string, runAt time.Time, args map[string]interface{}) (string, error) Listen(channel string, f ClientCallbackFunc) error RemoveJob(channel, id string) error Close() }
A Client interface provides all functions for add and consume jobs
type ClientCallbackFunc ¶
ClientCallbackFunc represents callback function for a specific channel
type ClientConfig ¶
type ClientConfig struct { Address string Logger logger LogLvl LogLevel ReadDeadline time.Duration WriteDeadline time.Duration }
ClientConfig contains every configuration to create a new Client
type Delegator ¶
type Delegator interface { OnIOError(index int) OnRequestReceived(index int, data []byte, addr string) OnJobReceived(data []byte) }
Delegator is an interface of methods that are used as callbacks in Protocol
type Job ¶
type Job struct { Channel string `json:"channel"` ID string `json:"id"` Args map[string]interface{} `json:"args"` RunAt time.Time `json:"run_at"` Status int `json:"status"` }
Job represents a scheduled job that will run in specific time
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
type ProtocolConfig ¶
type Scheduler ¶
type Scheduler interface {
Stop()
}
Scheduler is the core scheduling system that receives and processes jobs
func NewScheduler ¶
func NewScheduler(config SchedulerConfig) (Scheduler, error)
NewScheduler create new scheduler
Source Files ¶
Click to show internal directories.
Click to hide internal directories.