client

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLimit     = 50000
	DefaultCacheSize = 2048
)

Functions

func Decode

func Decode(buf []byte, fields []string, val any) error

func DecodeSlice

func DecodeSlice(buf []byte, fields []string, val any) error

func ErrorStatus

func ErrorStatus(err error) int

Types

type Client

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

func NewClient

func NewClient(url string, httpClient *http.Client) *Client

func (*Client) Async

func (c *Client) Async(ctx context.Context, path string, headers http.Header, result any) FutureResult

func (*Client) CacheAdd

func (c *Client) CacheAdd(key tezos.Address, val any)

func (*Client) CacheGet

func (c *Client) CacheGet(key tezos.Address) (any, bool)

func (*Client) DefaultHeaders

func (c *Client) DefaultHeaders() http.Header

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, headers http.Header) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, headers http.Header, result any) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, headers http.Header, data, result any) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, headers http.Header, data, result any) error

func (Client) Retries

func (c Client) Retries() int

func (Client) RetryDelay

func (c Client) RetryDelay() time.Duration

func (*Client) UseScriptCache

func (c *Client) UseScriptCache(cache *lru.TwoQueueCache[tezos.Address, any])

func (*Client) WithApiKey

func (c *Client) WithApiKey(s string) *Client

func (*Client) WithCacheSize

func (c *Client) WithCacheSize(sz int) *Client

func (*Client) WithHeader

func (c *Client) WithHeader(key, value string) *Client

func (*Client) WithLogger

func (c *Client) WithLogger(log log.Logger) *Client

func (*Client) WithRetry

func (c *Client) WithRetry(num int, delay time.Duration) *Client

func (*Client) WithTLS

func (c *Client) WithTLS(tc *tls.Config) *Client

func (*Client) WithTimeout

func (c *Client) WithTimeout(d time.Duration) *Client

func (*Client) WithUrl

func (c *Client) WithUrl(url string) *Client

func (*Client) WithUserAgent

func (c *Client) WithUserAgent(s string) *Client

type Decoder

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

type ErrApi added in v0.17.5

type ErrApi struct {
	Code      int    `json:"code"`
	Status_   int    `json:"status"`
	Message   string `json:"message"`
	Scope     string `json:"scope"`
	Detail    string `json:"detail"`
	RequestId string `json:"requestId"`
	Reason    string `json:"reason"`
	Request_  string `json:"request"`
}

func IsErrApi

func IsErrApi(err error) (*ErrApi, bool)

func (*ErrApi) Body added in v0.17.5

func (e *ErrApi) Body() []byte

func (*ErrApi) Error added in v0.17.5

func (e *ErrApi) Error() string

func (*ErrApi) Request added in v0.17.5

func (e *ErrApi) Request() string

func (*ErrApi) Status added in v0.17.5

func (e *ErrApi) Status() string

func (*ErrApi) StatusCode added in v0.17.5

func (e *ErrApi) StatusCode() int

func (*ErrApi) UnmarshalJSON added in v0.17.5

func (e *ErrApi) UnmarshalJSON(buf []byte) error

type ErrHttp added in v0.17.5

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

func (*ErrHttp) Body added in v0.17.5

func (e *ErrHttp) Body() []byte

func (*ErrHttp) Decode added in v0.17.5

func (e *ErrHttp) Decode(v interface{}) error

func (*ErrHttp) Error added in v0.17.5

func (e *ErrHttp) Error() string

func (*ErrHttp) Request added in v0.17.5

func (e *ErrHttp) Request() string

func (*ErrHttp) Status added in v0.17.5

func (e *ErrHttp) Status() string

func (*ErrHttp) StatusCode added in v0.17.5

func (e *ErrHttp) StatusCode() int

type ErrRateLimited

type ErrRateLimited struct {
	ErrHttp
	// contains filtered or unexported fields
}

func IsErrRateLimited

func IsErrRateLimited(err error) (*ErrRateLimited, bool)

func (*ErrRateLimited) Deadline

func (e *ErrRateLimited) Deadline() time.Duration

func (*ErrRateLimited) Done

func (e *ErrRateLimited) Done() <-chan struct{}

func (*ErrRateLimited) Error

func (e *ErrRateLimited) Error() string

func (*ErrRateLimited) Wait

func (e *ErrRateLimited) Wait(ctx context.Context) error

type FieldInfo

type FieldInfo struct {
	Idx      []int
	Name     string
	Alias    string
	Flags    int
	TypeName string
}

FieldInfo holds details for the representation of a single field.

func (FieldInfo) ContainsFlag

func (f FieldInfo) ContainsFlag(flag int) bool

func (*FieldInfo) DerefIndirect

func (finfo *FieldInfo) DerefIndirect(v interface{}) reflect.Value

Load value from interface, but only if the result will be usefully addressable.

func (FieldInfo) String

func (f FieldInfo) String() string

func (*FieldInfo) Value

func (finfo *FieldInfo) Value(v reflect.Value) reflect.Value

value returns v's field value corresponding to finfo. It's equivalent to v.FieldByIndex(finfo.idx), but initializes and dereferences pointers as necessary.

type FillMode

type FillMode string

type Filter

type Filter struct {
	Mode   FilterMode
	Column string
	Value  any
}

type FilterList

type FilterList []Filter

func (*FilterList) Add

func (l *FilterList) Add(mode FilterMode, col string, val ...any)

type FilterMode

type FilterMode string

type FormatType

type FormatType string

type FutureResult

type FutureResult chan *response

func (FutureResult) Done

func (r FutureResult) Done() bool

func (FutureResult) Receive

func (r FutureResult) Receive(ctx context.Context) error

type HTTPError added in v0.17.5

type HTTPError interface {
	error
	HTTPStatus
	Body() []byte
}

HTTPError retains HTTP status and error response body

func IsErrHttp

func IsErrHttp(err error) (HTTPError, bool)

type HTTPStatus added in v0.17.5

type HTTPStatus interface {
	Request() string // e.g. GET /...
	Status() string  // e.g. "200 OK"
	StatusCode() int // e.g. 200
}

HTTPStatus interface represents an unprocessed HTTP reply

type OrderType

type OrderType string

type Query

type Query struct {
	Server string
	Path   string
	Query  url.Values
}

func NewQuery

func NewQuery() Query

func ParseQuery

func ParseQuery(s string) (Query, error)

parse from http://server:port/prefix server:port/prefix server/prefix /prefix

func (Query) And

func (p Query) And(key string) Query

func (Query) AndArg

func (p Query) AndArg(key string, values ...any) Query

func (Query) AndEqual

func (p Query) AndEqual(key string, val any) Query

func (Query) AndFilter

func (p Query) AndFilter(key string, mode FilterMode, values ...any) Query

func (Query) AndGt

func (p Query) AndGt(key string, val any) Query

func (Query) AndGte

func (p Query) AndGte(key string, val any) Query

func (Query) AndIn

func (p Query) AndIn(key string, val ...any) Query

func (Query) AndLt

func (p Query) AndLt(key string, val any) Query

func (Query) AndLte

func (p Query) AndLte(key string, val any) Query

func (Query) AndNot

func (p Query) AndNot(key string) Query

func (Query) AndNotEqual

func (p Query) AndNotEqual(key string, val any) Query

func (Query) AndNotIn

func (p Query) AndNotIn(key string, val ...any) Query

func (Query) AndRange

func (p Query) AndRange(key string, from, to any) Query

func (Query) AndRegexp

func (p Query) AndRegexp(key string, re string) Query

func (Query) Asc

func (p Query) Asc() Query

func (Query) Check

func (p Query) Check() error

func (Query) Clone

func (p Query) Clone() Query

func (Query) Desc

func (p Query) Desc() Query

func (Query) Url

func (p Query) Url() string

func (Query) WithCursor

func (p Query) WithCursor(v uint64) Query

func (Query) WithFrom

func (p Query) WithFrom(t time.Time) Query

func (Query) WithLimit

func (p Query) WithLimit(v uint) Query

func (Query) WithMerge

func (p Query) WithMerge() Query

func (Query) WithMeta

func (p Query) WithMeta() Query

func (Query) WithOffset

func (p Query) WithOffset(v uint) Query

func (Query) WithOrder

func (p Query) WithOrder(o OrderType) Query

func (Query) WithPath

func (p Query) WithPath(path string) Query

func (Query) WithPrim

func (p Query) WithPrim() Query

func (Query) WithRights

func (p Query) WithRights() Query

func (Query) WithStorage

func (p Query) WithStorage() Query

func (Query) WithTags

func (p Query) WithTags(t ...string) Query

func (Query) WithTimeRange

func (p Query) WithTimeRange(from, to time.Time) Query

func (Query) WithTo

func (p Query) WithTo(t time.Time) Query

func (Query) WithUnpack

func (p Query) WithUnpack() Query

type StreamResponse

type StreamResponse struct {
	Runtime time.Duration
	Cursor  string
	Count   int
}

func NewStreamResponse

func NewStreamResponse(header http.Header) (StreamResponse, error)

type TableQuery

type TableQuery[T any] struct {
	Query   Query
	Table   string     // "op", "block", "chain", "flow"
	Format  FormatType // "json", "csv"
	Columns []string
	Limit   int
	Cursor  uint64
	Verbose bool
	Prim    bool
	NoFail  bool
	Filter  FilterList
	Order   OrderType // asc, desc
	// contains filtered or unexported fields
}

func NewTableQuery

func NewTableQuery[T any](c *Client, name string) *TableQuery[T]

func (*TableQuery[T]) AndEqual

func (q *TableQuery[T]) AndEqual(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndFilter

func (q *TableQuery[T]) AndFilter(mode FilterMode, col string, val ...any) *TableQuery[T]

func (*TableQuery[T]) AndGt

func (q *TableQuery[T]) AndGt(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndGte

func (q *TableQuery[T]) AndGte(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndIn

func (q *TableQuery[T]) AndIn(col string, val ...any) *TableQuery[T]

func (*TableQuery[T]) AndLt

func (q *TableQuery[T]) AndLt(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndLte

func (q *TableQuery[T]) AndLte(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndNotEqual

func (q *TableQuery[T]) AndNotEqual(col string, val any) *TableQuery[T]

func (*TableQuery[T]) AndNotIn

func (q *TableQuery[T]) AndNotIn(col string, val ...any) *TableQuery[T]

func (*TableQuery[T]) AndRange

func (q *TableQuery[T]) AndRange(col string, from, to any) *TableQuery[T]

func (*TableQuery[T]) AndRegexp

func (q *TableQuery[T]) AndRegexp(col string, re string) *TableQuery[T]

func (*TableQuery[T]) Asc

func (q *TableQuery[T]) Asc() *TableQuery[T]

func (TableQuery[T]) Check

func (p TableQuery[T]) Check() error

func (*TableQuery[T]) Desc

func (q *TableQuery[T]) Desc() *TableQuery[T]

func (*TableQuery[T]) GetColumns

func (q *TableQuery[T]) GetColumns() []string

func (*TableQuery[T]) ReplaceFilter

func (q *TableQuery[T]) ReplaceFilter(mode FilterMode, col string, val ...any) *TableQuery[T]

func (*TableQuery[T]) ResetFilter

func (q *TableQuery[T]) ResetFilter() *TableQuery[T]

func (TableQuery[T]) Run

func (q TableQuery[T]) Run(ctx context.Context) (*TableQueryResult[T], error)

func (TableQuery[T]) Url

func (p TableQuery[T]) Url() string

func (*TableQuery[T]) WithColumns

func (q *TableQuery[T]) WithColumns(cols ...string) *TableQuery[T]

func (*TableQuery[T]) WithCursor

func (q *TableQuery[T]) WithCursor(c uint64) *TableQuery[T]

func (*TableQuery[T]) WithFormat

func (q *TableQuery[T]) WithFormat(format FormatType) *TableQuery[T]

func (*TableQuery[T]) WithLimit

func (q *TableQuery[T]) WithLimit(limit int) *TableQuery[T]

func (*TableQuery[T]) WithNoFail

func (q *TableQuery[T]) WithNoFail() *TableQuery[T]

func (*TableQuery[T]) WithOrder

func (q *TableQuery[T]) WithOrder(order OrderType) *TableQuery[T]

func (*TableQuery[T]) WithPrim

func (q *TableQuery[T]) WithPrim() *TableQuery[T]

func (*TableQuery[T]) WithQuiet

func (q *TableQuery[T]) WithQuiet() *TableQuery[T]

func (*TableQuery[T]) WithVerbose

func (q *TableQuery[T]) WithVerbose() *TableQuery[T]

type TableQueryResult

type TableQueryResult[T any] struct {
	// contains filtered or unexported fields
}

func NewTableQueryResult

func NewTableQueryResult[T any](cols []string) *TableQueryResult[T]

func (*TableQueryResult[T]) Cursor

func (r *TableQueryResult[T]) Cursor() uint64

func (*TableQueryResult[T]) Last

func (r *TableQueryResult[T]) Last() (t T)

func (*TableQueryResult[T]) Len

func (r *TableQueryResult[T]) Len() int

func (*TableQueryResult[T]) Rows

func (r *TableQueryResult[T]) Rows() []T

func (*TableQueryResult[T]) UnmarshalJSON

func (r *TableQueryResult[T]) UnmarshalJSON(data []byte) error

type TypeInfo

type TypeInfo struct {
	Name     string
	Fields   []FieldInfo
	IsGoType bool
	TagName  string
}

TypeInfo holds details for the representation of a type.

func (TypeInfo) Aliases

func (t TypeInfo) Aliases() []string

func (TypeInfo) FieldNames

func (t TypeInfo) FieldNames() []string

func (TypeInfo) FilteredAliases

func (t TypeInfo) FilteredAliases(f int) []string

func (TypeInfo) Find

func (t TypeInfo) Find(name string) (FieldInfo, bool)

Jump to

Keyboard shortcuts

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