dao

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows              = sql.ErrNoRows
	ErrConstraintViolation = errors.New("constraint violation")
)

Functions

This section is empty.

Types

type AttemptDAO

type AttemptDAO interface {
	BaseDAO[entities.Attempt]
	UpdateStatus(ctx context.Context, id string, status entities.AttemptStatus) error
	UpdateStatusBatch(ctx context.Context, status entities.AttemptStatus, ids []string) error
	UpdateErrorCode(ctx context.Context, id string, status entities.AttemptStatus, code entities.AttemptErrorCode) error
	UpdateDelivery(ctx context.Context, id string, result *AttemptResult) error
	ListUnqueued(ctx context.Context, limit int) (list []*entities.Attempt, err error)
}

func NewAttemptDao

func NewAttemptDao(db *sqlx.DB, workspace bool) AttemptDAO

type AttemptDetailDAO added in v0.2.0

type AttemptDetailDAO interface {
	BaseDAO[entities.AttemptDetail]
	Upsert(ctx context.Context, attemptDetail *entities.AttemptDetail) error
}

func NewAttemptDetailDao added in v0.2.0

func NewAttemptDetailDao(db *sqlx.DB, workspace bool) AttemptDetailDAO

type AttemptResult

type AttemptResult struct {
	Request     *entities.AttemptRequest
	Response    *entities.AttemptResponse
	AttemptedAt types.Time
	Status      entities.AttemptStatus
	ErrorCode   *entities.AttemptErrorCode
	Exhausted   bool
}

type BaseDAO

type BaseDAO[T any] interface {
	Get(ctx context.Context, id string) (*T, error)
	Insert(ctx context.Context, entity *T) error
	Update(ctx context.Context, entity *T) error
	Delete(ctx context.Context, id string) (bool, error)
	Page(ctx context.Context, q query.Queryer) ([]*T, int64, error)
	List(ctx context.Context, q query.Queryer) ([]*T, error)
	Count(ctx context.Context, conditions map[string]interface{}) (int64, error)
	BatchInsert(ctx context.Context, entities []*T) error
}

type DAO

type DAO[T any] struct {
	// contains filtered or unexported fields
}

func NewDAO

func NewDAO[T any](db *sqlx.DB, opts Options) *DAO[T]

func (*DAO[T]) BatchInsert

func (dao *DAO[T]) BatchInsert(ctx context.Context, entities []*T) error

func (*DAO[T]) Count

func (dao *DAO[T]) Count(ctx context.Context, where map[string]interface{}) (total int64, err error)

func (*DAO[T]) DB

func (dao *DAO[T]) DB(ctx context.Context) Queryable

func (*DAO[T]) Delete

func (dao *DAO[T]) Delete(ctx context.Context, id string) (bool, error)

func (*DAO[T]) Get

func (dao *DAO[T]) Get(ctx context.Context, id string) (entity *T, err error)

func (*DAO[T]) Insert

func (dao *DAO[T]) Insert(ctx context.Context, entity *T) error

func (*DAO[T]) List

func (dao *DAO[T]) List(ctx context.Context, q query.Queryer) (list []*T, err error)

func (*DAO[T]) Page

func (dao *DAO[T]) Page(ctx context.Context, q query.Queryer) (list []*T, total int64, err error)

func (*DAO[T]) UnsafeDB

func (dao *DAO[T]) UnsafeDB(ctx context.Context) Queryable

func (*DAO[T]) Update

func (dao *DAO[T]) Update(ctx context.Context, entity *T) error

type EndpointDAO

type EndpointDAO interface {
	BaseDAO[entities.Endpoint]
}

func NewEndpointDAO

func NewEndpointDAO(db *sqlx.DB, workspace bool) EndpointDAO

type EventDAO

type EventDAO interface {
	BaseDAO[entities.Event]
	BatchInsertIgnoreConflict(ctx context.Context, events []*entities.Event) ([]string, error)
}

func NewEventDao

func NewEventDao(db *sqlx.DB, workspace bool) EventDAO

type Options added in v0.3.0

type Options struct {
	Table          string
	EntityName     string
	Workspace      bool
	CachePropagate bool
	CacheKey       constants.CacheKey
}

type PluginDAO added in v0.2.0

type PluginDAO interface {
	BaseDAO[entities.Plugin]
	ListEndpointPlugin(ctx context.Context, endpointId string) (list []*entities.Plugin, err error)
}

func NewPluginDAO added in v0.2.0

func NewPluginDAO(db *sqlx.DB, workspace bool) PluginDAO

type Queryable

type Queryable interface {
	sqlx.ExtContext
	GetContext(context.Context, interface{}, string, ...interface{}) error
	SelectContext(context.Context, interface{}, string, ...interface{}) error
}

Queryable is an interface to be used interchangeably for sqlx.Db and sqlx.Tx

type SourceDAO

type SourceDAO interface {
	BaseDAO[entities.Source]
}

func NewSourceDAO

func NewSourceDAO(db *sqlx.DB, workspace bool) SourceDAO

type WorkspaceDAO

type WorkspaceDAO interface {
	BaseDAO[entities.Workspace]
	GetDefault(ctx context.Context) (*entities.Workspace, error)
}

func NewWorkspaceDAO

func NewWorkspaceDAO(db *sqlx.DB) WorkspaceDAO

Jump to

Keyboard shortcuts

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