datasource

package
v0.0.0-...-983f3f3 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskAlreadyExists      = errors.New("task already exists")
	ErrTaskNotExists          = errors.New("task not exists")
	ErrTombstoneAlreadyExists = errors.New("tombstone already exists")
	ErrTombstoneNotExists     = errors.New("tombstone not exists")
)

Functions

func Init

func Init(c *Config) error

func Logger

func Logger() openlog.Logger

func RegisterPlugin

func RegisterPlugin(name string, engineFunc dataSourceEngine)

Types

type Config

type Config struct {
	Kind   string
	Logger openlog.Logger
}

type DataSource

type DataSource interface {
	TaskDao() TaskDao
	TombstoneDao() TombstoneDao
}

DataSource is the DAO layer

func GetDataSource

func GetDataSource() DataSource

type TaskDao

type TaskDao interface {
	// Create func is used for ut
	Create(ctx context.Context, task *sync.Task) (*sync.Task, error)
	Update(ctx context.Context, task *sync.Task) error
	Delete(ctx context.Context, tasks ...*sync.Task) error
	List(ctx context.Context, options ...TaskFindOption) ([]*sync.Task, error)
}

TaskDao provide api of Task entity

func GetTaskDao

func GetTaskDao() TaskDao

type TaskFindOption

type TaskFindOption func(options *TaskFindOptions)

func WithAction

func WithAction(action string) TaskFindOption

WithAction find task with action

func WithDataType

func WithDataType(dataType string) TaskFindOption

WithDataType find task with dataType

func WithDomain

func WithDomain(domain string) TaskFindOption

WithDomain find task with domain

func WithProject

func WithProject(project string) TaskFindOption

WithProject find task with project

func WithStatus

func WithStatus(status string) TaskFindOption

WithStatus find task with status

type TaskFindOptions

type TaskFindOptions struct {
	Domain       string
	Project      string
	Action       string
	Status       string
	ResourceType string
}

func NewTaskFindOptions

func NewTaskFindOptions() TaskFindOptions

type TombstoneDao

type TombstoneDao interface {
	Get(ctx context.Context, req *model.GetTombstoneRequest) (*sync.Tombstone, error)
	// Create func is used for ut
	Create(ctx context.Context, tombstone *sync.Tombstone) (*sync.Tombstone, error)
	Delete(ctx context.Context, tombstones ...*sync.Tombstone) error
	List(ctx context.Context, options ...TombstoneFindOption) ([]*sync.Tombstone, error)
}

TombstoneDao provide api of Tombstone entity

func GetTombstoneDao

func GetTombstoneDao() TombstoneDao

type TombstoneFindOption

type TombstoneFindOption func(options *TombstoneFindOptions)

func WithBeforeTimestamp

func WithBeforeTimestamp(timestamp int64) TombstoneFindOption

WithBeforeTimestamp find tombstone with beforeTimestamp

func WithResourceType

func WithResourceType(resourceType string) TombstoneFindOption

WithResourceType find tombstone with resource type

func WithTombstoneDomain

func WithTombstoneDomain(domain string) TombstoneFindOption

WithTombstoneDomain find tombstone with domain

func WithTombstoneProject

func WithTombstoneProject(project string) TombstoneFindOption

WithTombstoneProject find tombstone with project

type TombstoneFindOptions

type TombstoneFindOptions struct {
	Domain          string
	Project         string
	ResourceType    string
	BeforeTimestamp int64
}

func NewTombstoneFindOptions

func NewTombstoneFindOptions() TombstoneFindOptions

Directories

Path Synopsis
key

Jump to

Keyboard shortcuts

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