corroclient

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 9 Imported by: 5

README

corroclient

A go client for the https://github.com/superfly/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 ErrNoRows = errors.New("corroclient: no rows")
View Source
var ErrScan = errors.New("corroclient: scan error")

Functions

This section is empty.

Types

type Change

type Change struct {
	ChangeId   int64      `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) GetSubscription

func (c *CorroClient) GetSubscription(ctx context.Context, subscriptionId string) (*Subscription, error)

func (*CorroClient) PostSubscription

func (c *CorroClient) PostSubscription(ctx context.Context, statement Statement) (*Subscription, 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)

type EOQ

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

func (*EOQ) Type

func (e *EOQ) Type() EventType

type Error

type Error struct {
	Message string `json:"message"`
}

func (*Error) Type

func (e *Error) Type() EventType

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 Subscription

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

func (*Subscription) Close

func (s *Subscription) Close()

func (*Subscription) Events

func (s *Subscription) Events() <-chan Event

func (*Subscription) Id

func (s *Subscription) Id() string

Jump to

Keyboard shortcuts

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