persistence

package
v0.0.0-...-a12d374 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPersistence = errors.New("local persistence not available")
)

Functions

func ToWriter

func ToWriter(srv *Service) execution.OutputWriter

Types

type DbContext

type DbContext interface {
	GetScriptsRepository(projectID string) (scripts.Repository, error)
	GetDataRepository(projectID string) (Repository, error)
}

type QueryResult

type QueryResult struct {
	dal.QueryResult
	Data []RecordEntity
}

type Record

type Record struct {
	JobID     string      `json:"job_id"`
	ScriptID  string      `json:"script_id"`
	ScriptRev string      `json:"script_rev"`
	Data      interface{} `json:"data"`
}

type RecordEntity

type RecordEntity struct {
	dal.Entity
	Record
}

type Repository

type Repository interface {
	Create(ctx context.Context, record Record) (dal.Entity, error)

	Update(ctx context.Context, record Record) (dal.Entity, error)

	Get(ctx context.Context, id string) (RecordEntity, error)

	Delete(ctx context.Context, id string) error

	Find(ctx context.Context, q dal.Query) (QueryResult, error)

	FindByScriptID(ctx context.Context, scriptID string, q dal.Query) (QueryResult, error)
}

type Service

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

func NewService

func NewService(db DbContext) (*Service, error)

func (*Service) CreateRecord

func (service *Service) CreateRecord(ctx context.Context, job execution.Job, data interface{}) (dal.Entity, error)

func (*Service) DeleteRecord

func (service *Service) DeleteRecord(ctx context.Context, identity scripts.Identity, id string) error

func (*Service) FindProjectRecords

func (service *Service) FindProjectRecords(ctx context.Context, projectID string, q dal.Query) (QueryResult, error)

func (*Service) FindScriptRecords

func (service *Service) FindScriptRecords(ctx context.Context, identity scripts.Identity, q dal.Query) (QueryResult, error)

func (*Service) GetRecord

func (service *Service) GetRecord(ctx context.Context, identity scripts.Identity, id string) (RecordEntity, error)

func (*Service) UpdateRecord

func (service *Service) UpdateRecord(ctx context.Context, projectID string, record Record) (dal.Entity, error)

type WriterFn

type WriterFn func(job execution.Job, data []byte) error

func (WriterFn) Write

func (fn WriterFn) Write(job execution.Job, data []byte) error

Jump to

Keyboard shortcuts

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