docsbatch

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceDocs = "docs"
)

Variables

View Source
var (
	ErrEmptyRevision      = errors.New("document revision is empty")
	ErrRevisionChanged    = errors.New("document revision changed")
	ErrRequireEmpty       = errors.New("operation requires an empty batch")
	ErrTransactionDeleted = errors.New("batch transaction is already deleted")
	ErrInvalidID          = errors.New("invalid batch ID")
	ErrIdentityMismatch   = errors.New("batch identity mismatch")
	ErrNotFound           = errors.New("batch not found")
	ErrStoredIDMismatch   = errors.New("stored batch ID does not match filename")
)

Functions

func ValidateID

func ValidateID(batchID string) error

func ValidateIdentity

func ValidateIdentity(state *State, identity Identity) error

Types

type AppendOptions

type AppendOptions struct {
	BatchID      string
	Command      string
	Identity     Identity
	RevisionID   string
	Requests     []json.RawMessage
	RequireEmpty bool
}

type Identity

type Identity struct {
	Service    string
	DocumentID string
	Account    string
	Client     string
}

type Options

type Options struct {
	Now         func() time.Time
	NewID       func() (string, error)
	WriteFile   func(string, []byte, os.FileMode) error
	LockTimeout time.Duration
}

type Repository

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

func New

func New(dir string, options Options) *Repository

func (*Repository) Append

func (r *Repository) Append(options AppendOptions) (int, error)

func (*Repository) Create

func (r *Repository) Create(state State) (*State, error)

func (*Repository) Delete

func (r *Repository) Delete(batchID string) (*State, error)

func (*Repository) Ensure

func (r *Repository) Ensure() error

func (*Repository) Get

func (r *Repository) Get(batchID string) (*State, error)

func (*Repository) List

func (r *Repository) List() ([]Summary, error)

func (*Repository) Path

func (r *Repository) Path(batchID string) (string, error)

func (*Repository) Prune

func (r *Repository) Prune(olderThan time.Duration) ([]Summary, error)

func (*Repository) WithState

func (r *Repository) WithState(batchID string, fn func(*Transaction) error) error

type RequestEntry

type RequestEntry struct {
	AppendedAt time.Time       `json:"appended_at"`
	Command    string          `json:"command"`
	Request    json.RawMessage `json:"request"`
}

type State

type State struct {
	BatchID            string         `json:"batch_id"`
	Name               string         `json:"name,omitempty"`
	Service            string         `json:"service"`
	DocumentID         string         `json:"doc_id"`
	Account            string         `json:"account"`
	Client             string         `json:"client"`
	CreatedAt          time.Time      `json:"created_at"`
	UpdatedAt          time.Time      `json:"updated_at"`
	RequiredRevisionID string         `json:"required_revision_id,omitempty"`
	Requests           []RequestEntry `json:"requests"`
}

type Summary

type Summary struct {
	BatchID    string    `json:"batch_id"`
	Name       string    `json:"name,omitempty"`
	Service    string    `json:"service"`
	DocumentID string    `json:"doc_id"`
	Account    string    `json:"account"`
	Client     string    `json:"client"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	Requests   int       `json:"requests"`
}

type Transaction

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

func (*Transaction) PersistOrDelete

func (t *Transaction) PersistOrDelete() error

func (*Transaction) State

func (t *Transaction) State() *State

Jump to

Keyboard shortcuts

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