operation

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateID

func GenerateID() string

GenerateID creates a unique operation ID.

func Insert

func Insert(d *sql.DB, op *Operation) error

Insert creates a new operation in the database.

func MarkDone

func MarkDone(d *sql.DB, id string, response any, opErr map[string]any) error

MarkDone updates an operation as completed with a response or error.

func RegisterRoutes

func RegisterRoutes(mux *http.ServeMux, d *sql.DB)

RegisterRoutes registers the GET /operations and GET /operations/{id} endpoints.

Types

type Operation

type Operation struct {
	ID         string         `json:"id"`
	Path       string         `json:"path"`
	Done       bool           `json:"done"`
	Error      map[string]any `json:"error"`
	Response   any            `json:"response"`
	CreateTime string         `json:"create_time"`
}

Operation represents a long-running operation.

func Get

func Get(d *sql.DB, path string) (*Operation, error)

Get retrieves an operation by path.

func GetByID

func GetByID(d *sql.DB, id string) (*Operation, error)

GetByID retrieves an operation by ID.

func List

func List(d *sql.DB, pageSize int, pageToken string) ([]Operation, string, error)

List returns a paginated list of operations.

func (*Operation) ToMap

func (op *Operation) ToMap() map[string]any

ToMap converts an Operation to a map for JSON serialization.

Jump to

Keyboard shortcuts

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