domain

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidJobState added in v0.7.0

func IsValidJobState(state JobState) bool

IsValidJobState checks if the provided state is a valid JobState.

func IsValidJobType added in v0.7.0

func IsValidJobType(state JobType) bool

IsValidJobType checks if the provided JobType is valid

func ValidateDatasetID added in v0.7.0

func ValidateDatasetID(id string) error

ValidateDatasetID validates if the given id is a valid dataset ID

func ValidateZebedeeURI added in v0.7.0

func ValidateZebedeeURI(path string) error

ValidateZebedeeURI validates if the given path is a valid URI path

Types

type Event

type Event struct {
	CreatedAt   string `json:"created_at"`
	RequestedBy User   `json:"requested_by"`
	Action      string `json:"action"`
	JobID       string `json:"job_id"`
}

Event represents an action taken on a migration job

type Job

type Job struct {
	ID          string     `json:"id" bson:"_id"`
	LastUpdated time.Time  `json:"last_updated" bson:"last_updated"`
	State       JobState   `json:"state" bson:"state"`
	Config      *JobConfig `json:"config" bson:"config"`
	Links       JobLinks   `json:"links" bson:"links"`
}

Job represents a migration job

func NewJob

func NewJob(cfg *JobConfig, host string) Job

NewJob creates a new Job instance with the provided configuration and host

type JobConfig

type JobConfig struct {
	SourceID  string       `json:"source_id" bson:"source_id"`
	TargetID  string       `json:"target_id" bson:"target_id"`
	Type      JobType      `json:"type" bson:"type"`
	Validator JobValidator `json:"-" bson:"-"`
}

JobConfig represents the configuration for a migration job

func (*JobConfig) ValidateExternal added in v0.7.0

func (jc *JobConfig) ValidateExternal(ctx context.Context, appClients clients.ClientList) error

ValidateExternal performs validation of the JobConfig fields against external systems

func (*JobConfig) ValidateInternal added in v0.7.0

func (jc *JobConfig) ValidateInternal() []error

ValidateInternal performs internal validation of the JobConfig fields

type JobLinks struct {
	Self *LinkObject `bson:"self,omitempty"       json:"self,omitempty"`
}

JobLinks contains HATEOS links for a migration job

func NewJobLinks(id, host string) JobLinks

NewJobLinks creates JobLinks for a job with the given ID and host

type JobState added in v0.7.0

type JobState string

JobState represents the various states a migration job can be in.

const (
	JobStateSubmitted         JobState = "submitted"
	JobStateInReview          JobState = "in_review"
	JobStateApproved          JobState = "approved"
	JobStatePublished         JobState = "published"
	JobStateCompleted         JobState = "completed"
	JobStateMigrating         JobState = "migrating"
	JobStatePublishing        JobState = "publishing"
	JobStatePostPublishing    JobState = "post_publishing"
	JobStateReverting         JobState = "reverting"
	JobStateFailedPostPublish JobState = "failed_post_publish"
	JobStateFailedPublish     JobState = "failed_publish"
	JobStateFailedMigration   JobState = "failed_migration"
	JobStateCancelled         JobState = "cancelled"
)

func GetNonCancelledStates added in v0.7.0

func GetNonCancelledStates() []JobState

GetNonCancelledStates returns a slice of JobStates excluding the 'cancelled' state.

type JobType added in v0.7.0

type JobType string

JobType represents the type of migration job

const (
	JobTypeStaticDataset JobType = "static_dataset"
)

func (JobType) Validate added in v0.7.0

func (jt JobType) Validate() error

Validate checks if the JobType is valid and not empty

type JobValidator added in v0.7.0

type JobValidator interface {
	ValidateSourceID(sourceID string) error
	ValidateSourceIDWithExternal(ctx context.Context, sourceID string, appClients *clients.ClientList) error
	ValidateTargetID(targetID string) error
	ValidateTargetIDWithExternal(ctx context.Context, targetID string, appClients *clients.ClientList) error
}

JobValidator defines the contract for validating job configurations against external systems

func GetValidator added in v0.7.0

func GetValidator(jobType JobType) (JobValidator, error)

GetValidator retrieves the appropriate validator for the given jobType

type LinkObject added in v0.7.0

type LinkObject struct {
	HRef string `bson:"href,omitempty"  json:"href,omitempty"`
	ID   string `bson:"id,omitempty"    json:"id,omitempty"`
}

LinkObject represents a generic structure for all links

type StaticDatasetValidator added in v0.7.0

type StaticDatasetValidator struct{}

StaticDatasetValidator implements JobValidator for static dataset migration jobs

func (*StaticDatasetValidator) ValidateSourceID added in v0.7.0

func (v *StaticDatasetValidator) ValidateSourceID(sourceID string) error

ValidateSourceID validates if the given source ID is a valid Zebedee URI

func (*StaticDatasetValidator) ValidateSourceIDWithExternal added in v0.7.0

func (v *StaticDatasetValidator) ValidateSourceIDWithExternal(ctx context.Context, sourceID string, appClients *clients.ClientList) error

ValidateSourceIDWithExternal validates if the given source ID exists in Zebedee and is of the correct type

func (*StaticDatasetValidator) ValidateTargetID added in v0.7.0

func (v *StaticDatasetValidator) ValidateTargetID(targetID string) error

ValidateTargetID validates if the given id is a valid dataset ID

func (*StaticDatasetValidator) ValidateTargetIDWithExternal added in v0.7.0

func (v *StaticDatasetValidator) ValidateTargetIDWithExternal(ctx context.Context, targetID string, appClients *clients.ClientList) error

ValidateTargetIDWithExternal validates that the target dataset ID does not already exist

type User

type User struct {
	ID    string `json:"id"`
	Email string `json:"email"`
}

User represents a user who has performed an action on a migration job

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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