repository

package
v0.3.58 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobSetSubscriptions

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

Internal structure for storing in memory JobTables and Subscription JobSets Locks are used for concurrent access of map

func NewJobSetSubscriptions

func NewJobSetSubscriptions(subscribeMap map[string]*SubscribeTable) *JobSetSubscriptions

type JobStatus

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

JobStatus represents a job status

func NewJobStatus

func NewJobStatus(queue string, jobSetId string, jobId string, jobResponse js.JobServiceResponse) *JobStatus

NewJobStatus combines params into struct JobStatus and adds a timestamp

type JobTableUpdater

type JobTableUpdater interface {
	SubscribeJobSet(queue string, jobSet string)
	IsJobSetSubscribed(queue string, jobSet string) bool
	UpdateJobServiceDb(*JobStatus) error
	SetSubscriptionError(queue string, jobSet string, err string)
	GetSubscriptionError(queue string, jobSet string) string
	ClearSubscriptionError(queue string, jobSet string)
}

type JobTableUpdaterMock

type JobTableUpdaterMock struct {
	// ClearSubscriptionErrorFunc mocks the ClearSubscriptionError method.
	ClearSubscriptionErrorFunc func(queue string, jobSet string)

	// GetSubscriptionErrorFunc mocks the GetSubscriptionError method.
	GetSubscriptionErrorFunc func(queue string, jobSet string) string

	// IsJobSetSubscribedFunc mocks the IsJobSetSubscribed method.
	IsJobSetSubscribedFunc func(queue string, jobSet string) bool

	// SetSubscriptionErrorFunc mocks the SetSubscriptionError method.
	SetSubscriptionErrorFunc func(queue string, jobSet string, err string)

	// SubscribeJobSetFunc mocks the SubscribeJobSet method.
	SubscribeJobSetFunc func(queue string, jobSet string)

	// UpdateJobServiceDbFunc mocks the UpdateJobServiceDb method.
	UpdateJobServiceDbFunc func(jobStatus *JobStatus) error
	// contains filtered or unexported fields
}

JobTableUpdaterMock is a mock implementation of JobTableUpdater.

func TestSomethingThatUsesJobTableUpdater(t *testing.T) {

	// make and configure a mocked JobTableUpdater
	mockedJobTableUpdater := &JobTableUpdaterMock{
		ClearSubscriptionErrorFunc: func(queue string, jobSet string)  {
			panic("mock out the ClearSubscriptionError method")
		},
		GetSubscriptionErrorFunc: func(queue string, jobSet string) string {
			panic("mock out the GetSubscriptionError method")
		},
		IsJobSetSubscribedFunc: func(queue string, jobSet string) bool {
			panic("mock out the IsJobSetSubscribed method")
		},
		SetSubscriptionErrorFunc: func(queue string, jobSet string, err string)  {
			panic("mock out the SetSubscriptionError method")
		},
		SubscribeJobSetFunc: func(queue string, jobSet string)  {
			panic("mock out the SubscribeJobSet method")
		},
		UpdateJobServiceDbFunc: func(jobStatus *JobStatus) error {
			panic("mock out the UpdateJobServiceDb method")
		},
	}

	// use mockedJobTableUpdater in code that requires JobTableUpdater
	// and then make assertions.

}

func (*JobTableUpdaterMock) ClearSubscriptionError

func (mock *JobTableUpdaterMock) ClearSubscriptionError(queue string, jobSet string)

ClearSubscriptionError calls ClearSubscriptionErrorFunc.

func (*JobTableUpdaterMock) ClearSubscriptionErrorCalls

func (mock *JobTableUpdaterMock) ClearSubscriptionErrorCalls() []struct {
	Queue  string
	JobSet string
}

ClearSubscriptionErrorCalls gets all the calls that were made to ClearSubscriptionError. Check the length with:

len(mockedJobTableUpdater.ClearSubscriptionErrorCalls())

func (*JobTableUpdaterMock) GetSubscriptionError

func (mock *JobTableUpdaterMock) GetSubscriptionError(queue string, jobSet string) string

GetSubscriptionError calls GetSubscriptionErrorFunc.

func (*JobTableUpdaterMock) GetSubscriptionErrorCalls

func (mock *JobTableUpdaterMock) GetSubscriptionErrorCalls() []struct {
	Queue  string
	JobSet string
}

GetSubscriptionErrorCalls gets all the calls that were made to GetSubscriptionError. Check the length with:

len(mockedJobTableUpdater.GetSubscriptionErrorCalls())

func (*JobTableUpdaterMock) IsJobSetSubscribed

func (mock *JobTableUpdaterMock) IsJobSetSubscribed(queue string, jobSet string) bool

IsJobSetSubscribed calls IsJobSetSubscribedFunc.

func (*JobTableUpdaterMock) IsJobSetSubscribedCalls

func (mock *JobTableUpdaterMock) IsJobSetSubscribedCalls() []struct {
	Queue  string
	JobSet string
}

IsJobSetSubscribedCalls gets all the calls that were made to IsJobSetSubscribed. Check the length with:

len(mockedJobTableUpdater.IsJobSetSubscribedCalls())

func (*JobTableUpdaterMock) SetSubscriptionError

func (mock *JobTableUpdaterMock) SetSubscriptionError(queue string, jobSet string, err string)

SetSubscriptionError calls SetSubscriptionErrorFunc.

func (*JobTableUpdaterMock) SetSubscriptionErrorCalls

func (mock *JobTableUpdaterMock) SetSubscriptionErrorCalls() []struct {
	Queue  string
	JobSet string
	Err    string
}

SetSubscriptionErrorCalls gets all the calls that were made to SetSubscriptionError. Check the length with:

len(mockedJobTableUpdater.SetSubscriptionErrorCalls())

func (*JobTableUpdaterMock) SubscribeJobSet

func (mock *JobTableUpdaterMock) SubscribeJobSet(queue string, jobSet string)

SubscribeJobSet calls SubscribeJobSetFunc.

func (*JobTableUpdaterMock) SubscribeJobSetCalls

func (mock *JobTableUpdaterMock) SubscribeJobSetCalls() []struct {
	Queue  string
	JobSet string
}

SubscribeJobSetCalls gets all the calls that were made to SubscribeJobSet. Check the length with:

len(mockedJobTableUpdater.SubscribeJobSetCalls())

func (*JobTableUpdaterMock) UpdateJobServiceDb

func (mock *JobTableUpdaterMock) UpdateJobServiceDb(jobStatus *JobStatus) error

UpdateJobServiceDb calls UpdateJobServiceDbFunc.

func (*JobTableUpdaterMock) UpdateJobServiceDbCalls

func (mock *JobTableUpdaterMock) UpdateJobServiceDbCalls() []struct {
	JobStatus *JobStatus
}

UpdateJobServiceDbCalls gets all the calls that were made to UpdateJobServiceDb. Check the length with:

len(mockedJobTableUpdater.UpdateJobServiceDbCalls())

type SQLJobService

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

SQLJobService for persisting to DB.

func NewSQLJobService

func NewSQLJobService(jobSetSubscribe *JobSetSubscriptions, config *configuration.JobServiceConfiguration, db *sql.DB) *SQLJobService

func (*SQLJobService) CheckToUnSubscribe

func (s *SQLJobService) CheckToUnSubscribe(queue string, jobSet string, configTimeWithoutUpdates int64) bool

Checks JobSet table to make determine if we should unsubscribe from JobSet configTimeWithoutUpdates is a configurable value that is read from the config We allow unsubscribing if the jobset hasn't been updated in configTime

func (*SQLJobService) CleanupJobSetAndJobs

func (s *SQLJobService) CleanupJobSetAndJobs(queue string, jobSet string) (int64, error)

UnSubscribe to JobSet and delete all the jobs in the database

func (*SQLJobService) ClearSubscriptionError

func (s *SQLJobService) ClearSubscriptionError(queue string, jobSet string)

Clear subscription error if present

func (*SQLJobService) CreateTable

func (s *SQLJobService) CreateTable()

Create a Table from a hard-coded schema.

func (*SQLJobService) DeleteJobsInJobSet

func (s *SQLJobService) DeleteJobsInJobSet(queue string, jobSet string) (int64, error)

Delete Jobs in the database

func (*SQLJobService) GetJobStatus

func (s *SQLJobService) GetJobStatus(jobId string) (*js.JobServiceResponse, error)

Get the JobStatus given the jodId

func (*SQLJobService) GetSubscribedJobSets

func (s *SQLJobService) GetSubscribedJobSets() []SubscribedTuple

Get a list of SubscribedJobSets (Queue JobSet)

func (*SQLJobService) GetSubscriptionError

func (s *SQLJobService) GetSubscriptionError(queue string, jobSet string) string

Get subscription error if present

func (*SQLJobService) HealthCheck

func (s *SQLJobService) HealthCheck() (bool, error)

Simple Health Check to Verify if SqlLite is working.

func (*SQLJobService) IsJobSetSubscribed

func (s *SQLJobService) IsJobSetSubscribed(queue string, jobSet string) bool

Check if JobSet is in our map.

func (*SQLJobService) SetSubscriptionError

func (s *SQLJobService) SetSubscriptionError(queue string, jobSet string, err string)

Set subscription error if present

func (*SQLJobService) Setup

func (s *SQLJobService) Setup()

Call on a newly created SQLJobService object to setup the DB for use.

func (*SQLJobService) SubscribeJobSet

func (s *SQLJobService) SubscribeJobSet(queue string, jobSet string)

Mark our JobSet as being subscribed SubscribeTable contains Queue, JobSet and time when it was created.

func (*SQLJobService) UpdateJobServiceDb

func (s *SQLJobService) UpdateJobServiceDb(jobTable *JobStatus) error

Update database with JobTable.

func (*SQLJobService) UpdateJobSetTime

func (s *SQLJobService) UpdateJobSetTime(queue string, jobSet string) error

Update JobSet Map with time that a Job in that JobSet was requested

type SubscribeTable

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

func NewSubscribeTable

func NewSubscribeTable(queue string, jobSet string) *SubscribeTable

type SubscribedTuple

type SubscribedTuple struct {
	Queue  string
	JobSet string
}

Jump to

Keyboard shortcuts

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