corroclient

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 10 Imported by: 4

README

corroclient

Go Reference

A go client for the Corrosion API.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Overview

This package is used to interact with the corrosion API.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidChange = errors.New("corrosubs: Invalid change")
View Source
var ErrInvalidRow = errors.New("corrosubs: Invalid row")
View Source
var ErrMaxRetryExceeded = errors.New("corrosubs: lost connection")
View Source
var ErrMissedChange = errors.New("corrosubs: missed change")
View Source
var ErrNoRows = errors.New("corroclient: no rows")
View Source
var ErrScan = errors.New("corroclient: scan error")
View Source
var ErrSubscriptionClosed = errors.New("corrosubs: subscription closed")
View Source
var ErrUnknownEvent = errors.New("corroclient: unknown event in subscription")
View Source
var ErrUnrecoverableSub = errors.New("corrosubs: unrecoverable subscription")

Functions

This section is empty.

Types

type Change

type Change struct {
	ChangeId   uint64     `json:"change_id"`
	ChangeType ChangeType `json:"change_type"`
	Row        *Row       `json:"row"`
}

func (*Change) Type

func (c *Change) Type() EventType

type ChangeType

type ChangeType string
const (
	ChangeTypeInsert ChangeType = "insert"
	ChangeTypeUpdate ChangeType = "update"
	ChangeTypeDelete ChangeType = "delete"
)

type Columns

type Columns []string

func (Columns) Type

func (c Columns) Type() EventType

type Config

type Config struct {
	URL    string
	Bearer string
}

type CorroClient

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

func NewCorroClient

func NewCorroClient(config Config) *CorroClient

func (*CorroClient) Exec

func (c *CorroClient) Exec(ctx context.Context, stmts []Statement) (*ExecResult, error)

func (*CorroClient) Query

func (c *CorroClient) Query(ctx context.Context, stmt Statement) (*Rows, error)

func (*CorroClient) QueryRow

func (c *CorroClient) QueryRow(ctx context.Context, stmt Statement) (*Row, error)

func (*CorroClient) Subscribe added in v0.2.0

func (c *CorroClient) Subscribe(ctx context.Context, statement Statement, opts ...SubOpt) (*Subscription, error)

func (*CorroClient) UpdateSchema added in v0.2.0

func (c *CorroClient) UpdateSchema(ctx context.Context, stmts []string) (*ExecResult, error)

type EOQ

type EOQ struct {
	ChangeId uint64  `json:"change_id"`
	Time     float64 `json:"time"`
}

func (*EOQ) Type

func (e *EOQ) Type() EventType

type Error

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

func (*Error) Error added in v0.2.0

func (e *Error) Error() string

func (*Error) Type

func (e *Error) Type() EventType

func (*Error) Unwrap added in v0.2.0

func (e *Error) Unwrap() error

type Event

type Event interface {
	Type() EventType
}

type EventType

type EventType string
const (
	EventTypeRow     EventType = "row"
	EventTypeEOQ     EventType = "eoq"
	EventTypeChange  EventType = "change"
	EventTypeColumns EventType = "columns"
	EventTypeError   EventType = "error"
)

type ExecResult

type ExecResult struct {
	Results []Result `json:"results"`
}

func (*ExecResult) Errors

func (e *ExecResult) Errors() []error

type Result

type Result struct {
	Error       string  `json:"error"`
	RowAffected int     `json:"rows_affected"`
	Time        float64 `json:"time"`
}

func (*Result) Err

func (r *Result) Err() error

type Row

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

func (*Row) RowId

func (r *Row) RowId() int64

func (*Row) Scan

func (r *Row) Scan(dest ...any) error

Warning: Scan does not handle time.Time because of the various ways time can be stored in SQLite and JSON. You're responsible for converting time.Time yourself from numbers types or strings.

func (*Row) Type

func (r *Row) Type() EventType

type Rows

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

func (*Rows) Columns

func (r *Rows) Columns() []string

func (*Rows) Next

func (r *Rows) Next() bool

func (*Rows) Scan

func (r *Rows) Scan(dest ...any) error

Warning: Scan does not handle time.Time because of the various ways time can be stored in SQLite and JSON. You're responsible for converting time.Time yourself from numbers types or strings.

type Statement

type Statement struct {
	Query       string         `json:"query"`
	Params      []any          `json:"params,omitempty"`
	NamedParams map[string]any `json:"named_params,omitempty"`
}

type SubOpt added in v0.2.0

type SubOpt func(*subscribeOptions)

func WithBufferSize added in v0.2.0

func WithBufferSize(size int) SubOpt

func WithRetryOptions added in v0.2.0

func WithRetryOptions(backoff time.Duration, maxRetries int) SubOpt

func WithSkipRows added in v0.2.0

func WithSkipRows() SubOpt

type Subscription

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

func (*Subscription) Close

func (s *Subscription) Close()

func (*Subscription) Next added in v0.2.0

func (s *Subscription) Next() (Event, error)

Jump to

Keyboard shortcuts

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