mongo

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

type Mongo struct {
	config.MongoConfig

	Connection *mongodriver.MongoConnection
	// contains filtered or unexported fields
}

Mongo represents a mongo connection and health client

func (*Mongo) Checker

func (m *Mongo) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker is called by the healthcheck library to check the health state of this mongoDB instance

func (*Mongo) ClaimJob added in v0.15.0

func (m *Mongo) ClaimJob(ctx context.Context, pendingState, activeState domain.State) (*domain.Job, error)

ClaimJob claims a pending job for processing.

func (*Mongo) ClaimTask added in v0.15.0

func (m *Mongo) ClaimTask(ctx context.Context, pendingState, activeState domain.State) (*domain.Task, error)

ClaimTask claims a pending task for processing.

func (*Mongo) Close

func (m *Mongo) Close(ctx context.Context) error

Close represents mongo session closing within the context deadline

func (*Mongo) CountEventsByJobNumber added in v0.19.0

func (m *Mongo) CountEventsByJobNumber(ctx context.Context, jobNumber int) (int, error)

CountEventsByJobNumber returns the total count of events for a job.

func (*Mongo) CountTasksByJobNumber added in v0.19.0

func (m *Mongo) CountTasksByJobNumber(ctx context.Context, jobNumber int) (int, error)

CountTasksByJobNumber returns the total count of tasks for a job.

func (*Mongo) CreateEvent

func (m *Mongo) CreateEvent(ctx context.Context, event *domain.Event) error

CreateEvent creates a new event in the database.

func (*Mongo) CreateJob

func (m *Mongo) CreateJob(ctx context.Context, job *domain.Job) error

CreateJob creates a new migration job.

func (*Mongo) CreateTask added in v0.12.0

func (m *Mongo) CreateTask(ctx context.Context, task *domain.Task) error

CreateTask creates a new migration task.

func (*Mongo) GetJob

func (m *Mongo) GetJob(ctx context.Context, jobNumber int) (*domain.Job, error)

GetJob retrieves a job by its job number.

func (*Mongo) GetJobEvents added in v0.12.0

func (m *Mongo) GetJobEvents(ctx context.Context, jobNumber, limit, offset int) ([]*domain.Event, int, error)

GetJobEvents retrieves a list of migration events for a job with pagination.

func (*Mongo) GetJobStateCounts added in v1.1.0

func (m *Mongo) GetJobStateCounts(ctx context.Context) ([]StateCountResult, error)

GetJobStateCounts retrieves a summary of job counts by state, sorted by count descending.

func (*Mongo) GetJobTasks added in v0.11.0

func (m *Mongo) GetJobTasks(ctx context.Context, stateFilter []domain.State, jobNumber, limit, offset int) ([]*domain.Task, int, error)

GetJobTasks retrieves a list of migration tasks for a job with pagination.

func (*Mongo) GetJobs added in v0.10.0

func (m *Mongo) GetJobs(ctx context.Context, field sort.SortParameterField, direction sort.SortParameterDirection, stateFilter []domain.State, limit, offset int) ([]*domain.Job, int, error)

GetJobs retrieves a list of migration jobs with pagination.

func (*Mongo) GetJobsBySourceOrTargetAndState added in v0.35.1

func (m *Mongo) GetJobsBySourceOrTargetAndState(ctx context.Context, jc *domain.JobConfig, stateFilter []domain.State, limit, offset int) ([]*domain.Job, error)

GetJobsBySourceOrTargetAndState retrieves jobs based on the provided source ID or target ID and states.

func (*Mongo) GetJobsBySourceOrTargetID added in v0.35.1

func (m *Mongo) GetJobsBySourceOrTargetID(ctx context.Context, jc *domain.JobConfig, limit, offset int) ([]*domain.Job, error)

GetJobsBySourceOrTargetID retrieves jobs based on the provided source OR target ID.

func (*Mongo) GetJobsByState added in v0.15.0

func (m *Mongo) GetJobsByState(ctx context.Context, states []domain.State, limit, offset int) ([]*domain.Job, int, error)

GetJobsByState retrieves a list of migration jobs filtered by their states.

func (*Mongo) GetNextJobNumberCounter added in v0.19.0

func (m *Mongo) GetNextJobNumberCounter(ctx context.Context) (*domain.Counter, error)

GetNextJobNumberCounter increments the job number counter, in mongoDB, and then returns it

func (*Mongo) GetTask added in v0.15.0

func (m *Mongo) GetTask(ctx context.Context, taskID string) (*domain.Task, error)

GetTask retrieves a task by its ID.

func (*Mongo) Init

func (m *Mongo) Init(ctx context.Context) (err error)

Init returns an initialised Mongo object encapsulating a connection to the mongo server/cluster with the given configuration, and a health client to check the health of the mongo server/cluster

func (*Mongo) UpdateJob added in v0.15.0

func (m *Mongo) UpdateJob(ctx context.Context, job *domain.Job) error

UpdateJob updates an existing migration job.

func (*Mongo) UpdateJobState added in v0.20.0

func (m *Mongo) UpdateJobState(ctx context.Context, jobID string, oldState, newState domain.State, lastUpdated time.Time) error

UpdateJobState updates the state of a job

func (*Mongo) UpdateTask added in v0.15.0

func (m *Mongo) UpdateTask(ctx context.Context, task *domain.Task) error

UpdateTask updates an existing migration task.

func (*Mongo) UpdateTaskState added in v0.20.0

func (m *Mongo) UpdateTaskState(ctx context.Context, taskID string, newState domain.State, lastUpdated time.Time) error

UpdateTaskState updates the state of a task and returns the updated task.

type StateCountResult added in v1.1.0

type StateCountResult struct {
	State domain.State `bson:"_id"`
	Count int          `bson:"count"`
}

StateCountResult represents the result of a MongoDB aggregation that counts the number of jobs in each state.

Jump to

Keyboard shortcuts

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