cron

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cron is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerJob

type ContainerJob struct {
	Schedule  string
	Action    string
	Timeout   string
	Command   string
	Container types.Container
	// contains filtered or unexported fields
}

ContainerJob run a docker container on a schedule.

func (*ContainerJob) Run

func (j *ContainerJob) Run()

Run a docker container and log the output.

type Cron

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

Cron keeps track of any number of jobs, invoking the associated Job as specified by the schedule. It may be started and stopped.

func NewCron

func NewCron(parseSecond bool) *Cron

NewCron return a new Cron job runner.

func (*Cron) AddContainerJob

func (c *Cron) AddContainerJob(job ContainerJob) error

AddContainerJob add container job to the Cron to be run on the given schedule.

func (*Cron) AddJob

func (c *Cron) AddJob(job Job) error

AddJob adds a Job to the Cron to be run on the given schedule.

func (*Cron) AddJobs

func (c *Cron) AddJobs(jobs []Job) error

AddJobs adds jobs to the Cron.

func (*Cron) AddServiceJob

func (c *Cron) AddServiceJob(job ServiceJob) error

AddServiceJob add service job to the Cron to be run on the given schedule.

func (*Cron) LoadConfig

func (c *Cron) LoadConfig(filename string) error

LoadConfig read Job from file in JSON format and add them to Cron.

func (*Cron) RemoveContainerJob

func (c *Cron) RemoveContainerJob(ID string)

RemoveContainerJob remove container job from Cron.

func (*Cron) RemoveServiceJob

func (c *Cron) RemoveServiceJob(ID string)

RemoveServiceJob remove service job from Cron.

func (*Cron) Start

func (c *Cron) Start()

Start the Cron scheduler.

func (*Cron) Stop

func (c *Cron) Stop() context.Context

Stop the Cron scheduler.

type Cronner

type Cronner interface {
	AddContainerJob(job ContainerJob) error
	AddServiceJob(job ServiceJob) error
	RemoveContainerJob(ID string)
	RemoveServiceJob(ID string)
}

Cronner is an interface for adding job to cron

type DockerClient

type DockerClient interface {
	Close() error
	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
	ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
	ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
	ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
	ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
	Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
}

DockerClient is the client for docker

type Handler

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

Handler handle docker messages

func NewHandler

func NewHandler(cron Cronner) (*Handler, error)

NewHandler returns a docker handler

func (*Handler) ListenContainer

func (h *Handler) ListenContainer()

ListenContainer listen docker message for containers with cron schedule

func (*Handler) ListenService

func (h *Handler) ListenService()

ListenService listen docker message for services with cron schedule

func (*Handler) ScanContainer

func (h *Handler) ScanContainer() error

ScanContainer scan current containers for cron schedule

func (*Handler) ScanService

func (h *Handler) ScanService() error

ScanService scan current service for cron schedule

type Job

type Job struct {
	Schedule string   `json:"schedule"`
	Command  string   `json:"command"`
	Args     []string `json:"args"`
	// contains filtered or unexported fields
}

Job run a command with specified args on a schedule.

func (*Job) Run

func (j *Job) Run()

Run a Job and log the output.

type JobSynchroniser

type JobSynchroniser interface {
	Add(delta int)
	Done()
	Wait()
}

JobSynchroniser is an interface for testing sync.WaitGroup

type MockCronner

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

MockCronner is a mock of Cronner interface

func NewMockCronner

func NewMockCronner(ctrl *gomock.Controller) *MockCronner

NewMockCronner creates a new mock instance

func (*MockCronner) AddContainerJob

func (m *MockCronner) AddContainerJob(job ContainerJob) error

AddContainerJob mocks base method

func (*MockCronner) AddServiceJob

func (m *MockCronner) AddServiceJob(job ServiceJob) error

AddServiceJob mocks base method

func (*MockCronner) EXPECT

func (m *MockCronner) EXPECT() *MockCronnerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockCronner) RemoveContainerJob

func (m *MockCronner) RemoveContainerJob(ID string)

RemoveContainerJob mocks base method

func (*MockCronner) RemoveServiceJob

func (m *MockCronner) RemoveServiceJob(ID string)

RemoveServiceJob mocks base method

type MockCronnerMockRecorder

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

MockCronnerMockRecorder is the mock recorder for MockCronner

func (*MockCronnerMockRecorder) AddContainerJob

func (mr *MockCronnerMockRecorder) AddContainerJob(job interface{}) *gomock.Call

AddContainerJob indicates an expected call of AddContainerJob

func (*MockCronnerMockRecorder) AddServiceJob

func (mr *MockCronnerMockRecorder) AddServiceJob(job interface{}) *gomock.Call

AddServiceJob indicates an expected call of AddServiceJob

func (*MockCronnerMockRecorder) RemoveContainerJob

func (mr *MockCronnerMockRecorder) RemoveContainerJob(ID interface{}) *gomock.Call

RemoveContainerJob indicates an expected call of RemoveContainerJob

func (*MockCronnerMockRecorder) RemoveServiceJob

func (mr *MockCronnerMockRecorder) RemoveServiceJob(ID interface{}) *gomock.Call

RemoveServiceJob indicates an expected call of RemoveServiceJob

type MockDockerClient

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

MockDockerClient is a mock of DockerClient interface

func NewMockDockerClient

func NewMockDockerClient(ctrl *gomock.Controller) *MockDockerClient

NewMockDockerClient creates a new mock instance

func (*MockDockerClient) Close

func (m *MockDockerClient) Close() error

Close mocks base method

func (*MockDockerClient) ContainerExecAttach

func (m *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)

ContainerExecAttach mocks base method

func (*MockDockerClient) ContainerExecCreate

func (m *MockDockerClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)

ContainerExecCreate mocks base method

func (*MockDockerClient) ContainerExecInspect

func (m *MockDockerClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)

ContainerExecInspect mocks base method

func (*MockDockerClient) ContainerInspect

func (m *MockDockerClient) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)

ContainerInspect mocks base method

func (*MockDockerClient) ContainerList

func (m *MockDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)

ContainerList mocks base method

func (*MockDockerClient) ContainerRestart

func (m *MockDockerClient) ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error

ContainerRestart mocks base method

func (*MockDockerClient) ContainerStart

func (m *MockDockerClient) ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error

ContainerStart mocks base method

func (*MockDockerClient) ContainerStop

func (m *MockDockerClient) ContainerStop(ctx context.Context, container string, timeout *time.Duration) error

ContainerStop mocks base method

func (*MockDockerClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDockerClient) Events

func (m *MockDockerClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)

Events mocks base method

func (*MockDockerClient) ServiceList

func (m *MockDockerClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)

ServiceList mocks base method

func (*MockDockerClient) ServiceUpdate

func (m *MockDockerClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)

ServiceUpdate mocks base method

type MockDockerClientMockRecorder

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

MockDockerClientMockRecorder is the mock recorder for MockDockerClient

func (*MockDockerClientMockRecorder) Close

Close indicates an expected call of Close

func (*MockDockerClientMockRecorder) ContainerExecAttach

func (mr *MockDockerClientMockRecorder) ContainerExecAttach(ctx, execID, config interface{}) *gomock.Call

ContainerExecAttach indicates an expected call of ContainerExecAttach

func (*MockDockerClientMockRecorder) ContainerExecCreate

func (mr *MockDockerClientMockRecorder) ContainerExecCreate(ctx, container, config interface{}) *gomock.Call

ContainerExecCreate indicates an expected call of ContainerExecCreate

func (*MockDockerClientMockRecorder) ContainerExecInspect

func (mr *MockDockerClientMockRecorder) ContainerExecInspect(ctx, execID interface{}) *gomock.Call

ContainerExecInspect indicates an expected call of ContainerExecInspect

func (*MockDockerClientMockRecorder) ContainerInspect

func (mr *MockDockerClientMockRecorder) ContainerInspect(ctx, container interface{}) *gomock.Call

ContainerInspect indicates an expected call of ContainerInspect

func (*MockDockerClientMockRecorder) ContainerList

func (mr *MockDockerClientMockRecorder) ContainerList(ctx, options interface{}) *gomock.Call

ContainerList indicates an expected call of ContainerList

func (*MockDockerClientMockRecorder) ContainerRestart

func (mr *MockDockerClientMockRecorder) ContainerRestart(ctx, container, timeout interface{}) *gomock.Call

ContainerRestart indicates an expected call of ContainerRestart

func (*MockDockerClientMockRecorder) ContainerStart

func (mr *MockDockerClientMockRecorder) ContainerStart(ctx, container, options interface{}) *gomock.Call

ContainerStart indicates an expected call of ContainerStart

func (*MockDockerClientMockRecorder) ContainerStop

func (mr *MockDockerClientMockRecorder) ContainerStop(ctx, container, timeout interface{}) *gomock.Call

ContainerStop indicates an expected call of ContainerStop

func (*MockDockerClientMockRecorder) Events

func (mr *MockDockerClientMockRecorder) Events(ctx, options interface{}) *gomock.Call

Events indicates an expected call of Events

func (*MockDockerClientMockRecorder) ServiceList

func (mr *MockDockerClientMockRecorder) ServiceList(ctx, options interface{}) *gomock.Call

ServiceList indicates an expected call of ServiceList

func (*MockDockerClientMockRecorder) ServiceUpdate

func (mr *MockDockerClientMockRecorder) ServiceUpdate(ctx, serviceID, version, service, options interface{}) *gomock.Call

ServiceUpdate indicates an expected call of ServiceUpdate

type MockJobSynchroniser

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

MockJobSynchroniser is a mock of JobSynchroniser interface

func NewMockJobSynchroniser

func NewMockJobSynchroniser(ctrl *gomock.Controller) *MockJobSynchroniser

NewMockJobSynchroniser creates a new mock instance

func (*MockJobSynchroniser) Add

func (m *MockJobSynchroniser) Add(delta int)

Add mocks base method

func (*MockJobSynchroniser) Done

func (m *MockJobSynchroniser) Done()

Done mocks base method

func (*MockJobSynchroniser) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockJobSynchroniser) Wait

func (m *MockJobSynchroniser) Wait()

Wait mocks base method

type MockJobSynchroniserMockRecorder

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

MockJobSynchroniserMockRecorder is the mock recorder for MockJobSynchroniser

func (*MockJobSynchroniserMockRecorder) Add

func (mr *MockJobSynchroniserMockRecorder) Add(delta interface{}) *gomock.Call

Add indicates an expected call of Add

func (*MockJobSynchroniserMockRecorder) Done

Done indicates an expected call of Done

func (*MockJobSynchroniserMockRecorder) Wait

Wait indicates an expected call of Wait

type MockRunner

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

MockRunner is a mock of Runner interface

func NewMockRunner

func NewMockRunner(ctrl *gomock.Controller) *MockRunner

NewMockRunner creates a new mock instance

func (*MockRunner) AddJob

func (m *MockRunner) AddJob(spec string, cmd v3.Job) (v3.EntryID, error)

AddJob mocks base method

func (*MockRunner) EXPECT

func (m *MockRunner) EXPECT() *MockRunnerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRunner) Remove

func (m *MockRunner) Remove(id v3.EntryID)

Remove mocks base method

func (*MockRunner) Start

func (m *MockRunner) Start()

Start mocks base method

func (*MockRunner) Stop

func (m *MockRunner) Stop() context.Context

Stop mocks base method

type MockRunnerMockRecorder

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

MockRunnerMockRecorder is the mock recorder for MockRunner

func (*MockRunnerMockRecorder) AddJob

func (mr *MockRunnerMockRecorder) AddJob(spec, cmd interface{}) *gomock.Call

AddJob indicates an expected call of AddJob

func (*MockRunnerMockRecorder) Remove

func (mr *MockRunnerMockRecorder) Remove(id interface{}) *gomock.Call

Remove indicates an expected call of Remove

func (*MockRunnerMockRecorder) Start

func (mr *MockRunnerMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockRunnerMockRecorder) Stop

func (mr *MockRunnerMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

type Runner

type Runner interface {
	AddJob(spec string, cmd cron.Job) (cron.EntryID, error)
	Remove(id cron.EntryID)
	Start()
	Stop() context.Context
}

Runner is an interface for testing robfig/cron

type ServiceJob

type ServiceJob struct {
	Schedule         string
	Action           string
	ServiceID        string
	ServiceName      string
	ServiceVersion   swarm.Version
	ServiceCreatedAt time.Time
	Service          swarm.Service
	// contains filtered or unexported fields
}

ServiceJob run a docker service task on a schedule.

func (*ServiceJob) Run

func (j *ServiceJob) Run()

Run a docker container and log the output.

Jump to

Keyboard shortcuts

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