storage

package
v0.0.0-...-d17635e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScheduleStatusIdle      = "IDLE"
	ScheduleStatusQueued    = "QUEUED"
	ScheduleStatusSucceeded = "SUCCEEDED"
	ScheduleStatusCanceled  = "CANCELED"
	ScheduleStatusFailed    = "FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	DueAt   time.Time         `json:"dueAt" dynamodbav:"dueAt,unixtime"`
	URL     string            `json:"url" dynamodbav:"url"`
	Method  string            `json:"method" dynamodbav:"method"`
	Headers map[string]string `json:"headers,omitempty" dynamodbav:"headers,omitempty"`
	Body    string            `json:"body,omitempty" dynamodbav:"body,omitempty"`
}

type Database

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

func NewDatabase

func NewDatabase(dynamodb dynamodbiface.DynamoDBAPI) *Database

func (*Database) Cancel

func (srv *Database) Cancel(ctx context.Context, id string) (bool, error)

func (*Database) Create

func (srv *Database) Create(
	ctx context.Context,
	input CreateInput) (string, error)

func (*Database) Get

func (srv *Database) Get(ctx context.Context, id string) (*Schedule, error)

func (*Database) List

func (srv *Database) List(ctx context.Context, input ListInput) (*List, error)

type DateRange

type DateRange struct {
	From time.Time `json:"from"`
	To   time.Time `json:"to"`
}

type List

type List struct {
	Schedules []*Schedule `json:"schedules"`
	NextKey   *ListKey    `json:"nextKey,omitempty"`
}

type ListInput

type ListInput struct {
	Status   string     `json:"status,omitempty"`
	DueAt    *DateRange `json:"dueAt,omitempty"`
	StartKey *ListKey   `json:"startKey,omitempty"`
	Limit    int64      `json:"limit"`
}

type ListKey

type ListKey struct {
	ID     string  `json:"id" dynamodbav:"id"`
	DueAt  *int64  `json:"dueAt" dynamodbav:"dueAt"`
	Status *string `json:"status,omitempty" dynamodbav:"status,omitempty"`
}

type Schedule

type Schedule struct {
	ID          string            `json:"id" dynamodbav:"id"`
	DueAt       time.Time         `json:"dueAt" dynamodbav:"dueAt,unixtime"`
	URL         string            `json:"url" dynamodbav:"url"`
	Method      string            `json:"method" dynamodbav:"method"`
	Headers     map[string]string `json:"headers,omitempty" dynamodbav:"headers,omitempty"`
	Body        *string           `json:"body,omitempty" dynamodbav:"body,omitempty"`
	Status      string            `json:"status" dynamodbav:"status"`
	StartedAt   *time.Time        `json:"startedAt,omitempty" dynamodbav:"startedAt,unixtime,omitempty"`
	CompletedAt *time.Time        `json:"completedAt,omitempty" dynamodbav:"completedAt,unixtime,omitempty"`
	CanceledAt  *time.Time        `json:"canceledAt,omitempty" dynamodbav:"canceledAt,unixtime,omitempty"`
	Result      *string           `json:"result,omitempty" dynamodbav:"result,omitempty"`
	CreatedAt   time.Time         `json:"createdAt" dynamodbav:"createdAt,unixtime"`
}

type Storage

type Storage interface {
	Create(context.Context, CreateInput) (string, error)

	Cancel(context.Context, string) (bool, error)

	Get(context.Context, string) (*Schedule, error)

	List(context.Context, ListInput) (*List, error)
}

Jump to

Keyboard shortcuts

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