storage

package
v0.0.0-...-6290bb2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drop

func Drop()

func HasMinAlertFields

func HasMinAlertFields(strategy string, endpoint string, method string) bool

func NewStorage

func NewStorage(cfg *config.Configs) (Storage, Closer)

It connects to a db

func Seed

func Seed()

Types

type APIStorage

type APIStorage interface {
	GetClaimedJobs(limit int, offset int) []*job.Job
	GetClaimedJobsExecutions(jobId uuid.UUID, limit int, offset int) []*job.JobExecution
	Connected() bool
	GetSSLVersion() (bool, string)
	CreateJob(j CreateJobInput) error
	UpdateJob(j UpdateJobInput) error
}

type Closer

type Closer func()

type CreateJobInput

type CreateJobInput struct {
	Name            string            `json:"name"`
	CronExpString   string            `json:"cronexp"`
	MaxRetries      int               `json:"maxRetries"`
	Endpoint        string            `json:"endpoint"`
	HttpMethod      string            `json:"httpmethod"`
	Headers         map[string]string `json:"headers"`
	SuccessStatuses []int             `json:"successStatuses"`
	AlertStrategy   string            `json:"alertStrategy"`
	AlertMethod     string            `json:"alertMethod"`
	AlertEndpoint   string            `json:"alertEndpoint"`
	AlertPayload    string            `json:"alertPayload"`
	AlertHeaders    map[string]string `json:"alertHeaders"`
}

type JobUpdates

type JobUpdates struct {
	Job_name         string
	Cron_exp_string  string
	Endpoint         string
	Httpmethod       string
	Max_retries      int
	Headers_string   string
	Success_statuses []int
	Tls_client_cert  string
	Alert_strategy   string
	Alert_endpoint   string
	Alert_method     string
	Updated_at       int64
}

type SQLStorage

type SQLStorage struct {
	Db *pgxpool.Pool
}

func (*SQLStorage) Connected

func (sqls *SQLStorage) Connected() bool

func (*SQLStorage) CreateJob

func (sqls *SQLStorage) CreateJob(j CreateJobInput) error

func (*SQLStorage) GetAvailableJobs

func (sqls *SQLStorage) GetAvailableJobs(limit int) []*job.Job

Gets pending to be claimed jobs from the db and returns a list of all jobs that could be claimed

func (*SQLStorage) GetClaimedJobs

func (sqls *SQLStorage) GetClaimedJobs(limit int, offset int) []*job.Job

Gets get jobs claimed by this instance

func (*SQLStorage) GetClaimedJobsExecutions

func (sqls *SQLStorage) GetClaimedJobsExecutions(jobId uuid.UUID, limit int, offset int) []*job.JobExecution

Gets get jobs claimed by this instance

func (*SQLStorage) GetClient

func (sqls *SQLStorage) GetClient() *pgxpool.Pool

Returns the raw client

func (*SQLStorage) GetJobUpdates

func (s *SQLStorage) GetJobUpdates(jobId uuid.UUID) *JobUpdates

func (*SQLStorage) GetSSLVersion

func (sqls *SQLStorage) GetSSLVersion() (bool, string)

Writes an execution result in the db

func (*SQLStorage) ListenForChanges

func (s *SQLStorage) ListenForChanges(jobIDUpdatedCh chan uuid.UUID, ctx context.Context)

Creates a gorutine that waits for messages in a loop and sends them over "jobIDUpdatedCh".

It will block until the waiting loop starts

func (*SQLStorage) RegisterSelf

func (sqls *SQLStorage) RegisterSelf()

Should register the url, name of the application and so on in the db

func (*SQLStorage) ReleaseAll

func (sqls *SQLStorage) ReleaseAll(j []*job.Job) error

Writes an execution result in the db

func (*SQLStorage) StopListeningForChanges

func (s *SQLStorage) StopListeningForChanges() error

func (*SQLStorage) UpdateJob

func (sqls *SQLStorage) UpdateJob(j UpdateJobInput) error

func (*SQLStorage) WriteDone

func (sqls *SQLStorage) WriteDone(j *job.Job) error

Writes an execution result in the db

type SchedulerStorage

type SchedulerStorage interface {
	ListenForChanges(ch chan uuid.UUID, ctx context.Context)
	StopListeningForChanges() error
	GetJobUpdates(jobId uuid.UUID) *JobUpdates
	GetAvailableJobs(limit int) []*job.Job
	WriteDone(*job.Job) error
	RegisterSelf()
	GetClient() *pgxpool.Pool
	ReleaseAll(j []*job.Job) error
}

type Storage

type Storage interface {
	SchedulerStorage
	APIStorage
}

An interface that should help to describe what the Storage is doing

type UpdateJobInput

type UpdateJobInput struct {
	Id              uuid.UUID         `json:"id"`
	Name            string            `json:"name"`
	CronExpString   string            `json:"cronexp"`
	MaxRetries      int               `json:"maxRetries"`
	Endpoint        string            `json:"endpoint"`
	HttpMethod      string            `json:"httpmethod"`
	Headers         map[string]string `json:"headers"`
	SuccessStatuses []int             `json:"successStatuses"`
	AlertStrategy   string            `json:"alertStrategy"`
	AlertMethod     string            `json:"alertMethod"`
	AlertEndpoint   string            `json:"alertEndpoint"`
	AlertPayload    string            `json:"alertPayload"`
	AlertHeaders    map[string]string `json:"alertHeaders"`
}

Jump to

Keyboard shortcuts

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