storage

package
v0.0.0-...-5b6efc0 Latest Latest
Warning

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

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

Documentation

Overview

utils for creating filters and sorting parameters from query strings

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound            = fmt.Errorf("not found")
	ErrNoAccess            = fmt.Errorf("no access")
	ErrNewerDocumentExists = fmt.Errorf("newer document exists")
)

Functions

func CheckWorkspaceAccess

func CheckWorkspaceAccess(ctx context.Context, ns string) bool

Some of the db-accessors below require an authenticated context TODO: method should be removed and replaced by granularity access control method

func DereferenceComponent

func DereferenceComponent(ctx context.Context, client ComponentClient, cmp interface{}) (models.Component, error)

func NewMongoClientFromConfig

func NewMongoClientFromConfig(config DbConfig) (*mongo.Client, error)

func ProjectionFromBsonTags

func ProjectionFromBsonTags(fields []reflect.StructField) []bson.E

Types

type ComponentClient

type ComponentClient interface {
	ListComponentsMetadata(ctx context.Context, pagination Pagination, filters []string, sorts []string) (models.MetadataList, error)
	ListComponentVersionsMetadata(ctx context.Context, id models.ComponentReference, pagination Pagination, sorts []string) (models.MetadataList, error)
	GetComponent(ctx context.Context, id interface{}) (models.Component, error)
	CreateComponent(ctx context.Context, node models.Component) error
	PutComponent(ctx context.Context, node models.Component) error
	PatchComponent(ctx context.Context, node models.Component, oldTimestamp time.Time) (models.Component, error)

	ListWorkflowsMetadata(ctx context.Context, pagination Pagination, filter []string, sorts []string) (models.MetadataWorkspaceList, error)
	ListWorkflowVersionsMetadata(ctx context.Context, id models.ComponentReference, pagination Pagination, sorts []string) (models.MetadataWorkspaceList, error)
	GetWorkflow(ctx context.Context, id interface{}) (models.Workflow, error)
	CreateWorkflow(ctx context.Context, node models.Workflow) error
	PutWorkflow(ctx context.Context, node models.Workflow) error
	PatchWorkflow(ctx context.Context, node models.Workflow, oldTimestamp time.Time) (models.Workflow, error)

	ListJobsMetadata(ctx context.Context, pagination Pagination, filter []string, sorts []string) (models.MetadataWorkspaceList, error)
	GetJob(ctx context.Context, id models.ComponentReference) (models.Job, error)
	CreateJob(ctx context.Context, node models.Job) error

	DeleteDocument(ctx context.Context, kind DocumentKind, id models.CRefVersion) (models.CRefVersion, error)

	AddJobEvents(ctx context.Context, id models.ComponentReference, events []models.JobEvent) error
}

func NewMongoStorageClient

func NewMongoStorageClient(client *mongo.Client, dbname string) ComponentClient

func NewMongoStorageClientFromConfig

func NewMongoStorageClientFromConfig(config DbConfig, client *mongo.Client) (ComponentClient, error)

type CosmosConfig

type CosmosConfig struct {
	/*
		Credentials from azure layout:
		   {
		     "PrimaryMongoDBConnectionString": "...=",
		     "PrimaryReadOnlyMongoDBConnectionString": "...=",
		     "SecondaryMongoDBConnectionString": "...=",
		     "SecondaryReadOnlyMongoDBConnectionString": "...=",
		     "northeuropeEndpoint": "...",
		     "primaryEndpoint": "...",
		     "primaryMasterKey": "...==",
		     "primaryReadonlyMasterKey": "...==",
		     "secondaryMasterKey": "...==",
		     "secondaryReadonlyMasterKey": "...=="
		   }

	*/
	Credentials string `mapstructure:"credentials"`
}

func (CosmosConfig) ConnectionString

func (c CosmosConfig) ConnectionString() (string, error)

type DbConfig

type DbConfig struct {
	Select string
	DbName string
	Config map[string]interface{}
}

type DocumentKind

type DocumentKind string
const (
	JobKind       DocumentKind = "job"
	ComponentKind DocumentKind = "component"
	WorkflowKind  DocumentKind = "workflow"
)

type JoinOp

type JoinOp string
const (
	AND JoinOp = "$and"
)

type LocalStorageClientImpl

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

func NewLocalNodeStorageClient

func NewLocalNodeStorageClient() *LocalStorageClientImpl

func (*LocalStorageClientImpl) CreateComponent

func (c *LocalStorageClientImpl) CreateComponent(ctx context.Context, node models.Component, workspace string) error

func (*LocalStorageClientImpl) CreateJob

func (c *LocalStorageClientImpl) CreateJob(ctx context.Context, node models.Job) error

func (*LocalStorageClientImpl) CreateWorkflow

func (c *LocalStorageClientImpl) CreateWorkflow(ctx context.Context, node models.Workflow) error

func (*LocalStorageClientImpl) GetComponent

func (*LocalStorageClientImpl) GetJob

jobs

func (*LocalStorageClientImpl) GetWorkflow

func (*LocalStorageClientImpl) ListComponentsMetadata

func (c *LocalStorageClientImpl) ListComponentsMetadata(ctx context.Context, pagination Pagination, workspaceFilter []string) ([]models.Metadata, error)

func (*LocalStorageClientImpl) ListJobsMetadata

func (c *LocalStorageClientImpl) ListJobsMetadata(ctx context.Context, pagination Pagination, workspaceFilter []string) ([]models.Metadata, error)

func (*LocalStorageClientImpl) ListWorkflowsMetadata

func (c *LocalStorageClientImpl) ListWorkflowsMetadata(ctx context.Context, pagination Pagination, workspaceFilter []string) ([]models.Metadata, error)

type MongoConfig

type MongoConfig struct {
	Address string
	Port    int
}

func (MongoConfig) ConnectionString

func (c MongoConfig) ConnectionString() (string, error)

type MongoStorageClient

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

func (*MongoStorageClient) AddJobEvents

func (c *MongoStorageClient) AddJobEvents(ctx context.Context, id models.ComponentReference, events []models.JobEvent) error

func (*MongoStorageClient) CreateComponent

func (c *MongoStorageClient) CreateComponent(ctx context.Context, node models.Component) error

func (*MongoStorageClient) CreateJob

func (c *MongoStorageClient) CreateJob(ctx context.Context, node models.Job) error

func (*MongoStorageClient) CreateWorkflow

func (c *MongoStorageClient) CreateWorkflow(ctx context.Context, node models.Workflow) error

func (*MongoStorageClient) DeleteDocument

func (*MongoStorageClient) GetAllVersions

func (c *MongoStorageClient) GetAllVersions(ctx context.Context, cref models.ComponentReference, getter getCollection) ([]models.Version, error)

func (*MongoStorageClient) GetComponent

func (c *MongoStorageClient) GetComponent(ctx context.Context, id interface{}) (models.Component, error)

func (*MongoStorageClient) GetJob

func (*MongoStorageClient) GetLatestVersion

func (c *MongoStorageClient) GetLatestVersion(ctx context.Context, cref models.ComponentReference, getter getCollection) (models.Version, error)

func (*MongoStorageClient) GetWorkflow

func (c *MongoStorageClient) GetWorkflow(ctx context.Context, id interface{}) (models.Workflow, error)

func (*MongoStorageClient) ListComponentVersionsMetadata

func (c *MongoStorageClient) ListComponentVersionsMetadata(ctx context.Context, id models.ComponentReference, pagination Pagination, sorts []string) (models.MetadataList, error)

func (*MongoStorageClient) ListComponentsMetadata

func (c *MongoStorageClient) ListComponentsMetadata(ctx context.Context, pagination Pagination, filterstrings []string, sorts []string) (models.MetadataList, error)

func (*MongoStorageClient) ListJobsMetadata

func (c *MongoStorageClient) ListJobsMetadata(ctx context.Context, pagination Pagination, filterstrings []string, sorts []string) (models.MetadataWorkspaceList, error)

func (*MongoStorageClient) ListWorkflowVersionsMetadata

func (c *MongoStorageClient) ListWorkflowVersionsMetadata(ctx context.Context, id models.ComponentReference, pagination Pagination, sorts []string) (models.MetadataWorkspaceList, error)

func (*MongoStorageClient) ListWorkflowsMetadata

func (c *MongoStorageClient) ListWorkflowsMetadata(ctx context.Context, pagination Pagination, filterstrings []string, sorts []string) (models.MetadataWorkspaceList, error)

func (*MongoStorageClient) PatchComponent

func (c *MongoStorageClient) PatchComponent(ctx context.Context, node models.Component, oldTimestamp time.Time) (models.Component, error)

func (*MongoStorageClient) PatchWorkflow

func (c *MongoStorageClient) PatchWorkflow(ctx context.Context, node models.Workflow, oldTimestamp time.Time) (models.Workflow, error)

func (*MongoStorageClient) PutComponent

func (c *MongoStorageClient) PutComponent(ctx context.Context, node models.Component) error

func (*MongoStorageClient) PutWorkflow

func (c *MongoStorageClient) PutWorkflow(ctx context.Context, node models.Workflow) error

type MongoVolumeClientImpl

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

Implements storage.VolumeClient

func (*MongoVolumeClientImpl) DeleteVolume

func (*MongoVolumeClientImpl) GetVolume

func (*MongoVolumeClientImpl) ListVolumes

func (c *MongoVolumeClientImpl) ListVolumes(ctx context.Context, pagination Pagination, filterstrings []string, sortstrings []string) (models.FlowifyVolumeList, error)

func (*MongoVolumeClientImpl) PutVolume

type Order

type Order int
const (
	ASC  Order = +1
	DESC Order = -1
)

type Pagination

type Pagination struct {
	Limit int
	Skip  int
}

type VolumeClient

type VolumeClient interface {
	ListVolumes(ctx context.Context, pagination Pagination, filters []string, sorts []string) (models.FlowifyVolumeList, error)
	GetVolume(ctx context.Context, id models.ComponentReference) (models.FlowifyVolume, error)
	PutVolume(ctx context.Context, vol models.FlowifyVolume) error
	DeleteVolume(ctx context.Context, id models.ComponentReference) error
}

func NewMongoVolumeClientFromConfig

func NewMongoVolumeClientFromConfig(config DbConfig, client *mongo.Client) (VolumeClient, error)

Jump to

Keyboard shortcuts

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