utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceBusy = errors.New("resource busy, try again")
View Source
var ErrUnknownLogLevel = errors.New("unknown log level (known: debug, info, warn, error)")
View Source
var ErrUnknownNetwork = errors.New("unknown network (known: mainnet, goerli, goerli2, integration)")

Functions

func All added in v0.6.0

func All[T any](slice []T, f func(T) bool) bool

All returns true if all elements match the given predicate

func Filter added in v0.6.0

func Filter[T any](slice []T, f func(T) bool) []T

func Flatten added in v0.4.0

func Flatten[T any](sl ...[]T) []T

func Gzip64Decode added in v0.4.0

func Gzip64Decode(data string) ([]byte, error)

func Gzip64Encode added in v0.4.0

func Gzip64Encode(data []byte) (string, error)

func HexToFelt added in v0.2.1

func HexToFelt(t testing.TB, hex string) *felt.Felt

func Map added in v0.6.0

func Map[T1, T2 any](slice []T1, f func(T1) T2) []T2

func Ptr added in v0.6.0

func Ptr[T any](v T) *T

func RunAndWrapOnError added in v0.6.2

func RunAndWrapOnError(runnable func() error, existingErr error) error

Types

type LogLevel

type LogLevel int
const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
)

func (*LogLevel) MarshalJSON added in v0.6.0

func (l *LogLevel) MarshalJSON() ([]byte, error)

func (LogLevel) MarshalYAML added in v0.6.0

func (l LogLevel) MarshalYAML() (interface{}, error)

func (*LogLevel) Set added in v0.2.1

func (l *LogLevel) Set(s string) error

func (LogLevel) String

func (l LogLevel) String() string

func (*LogLevel) Type added in v0.2.1

func (l *LogLevel) Type() string

func (*LogLevel) UnmarshalText added in v0.2.1

func (l *LogLevel) UnmarshalText(text []byte) error

type Logger

type Logger interface {
	SimpleLogger
	pebble.Logger
}

type Network

type Network int
const (
	MAINNET Network = iota + 1
	GOERLI
	GOERLI2
	INTEGRATION
)

func (Network) ChainID added in v0.2.1

func (n Network) ChainID() *felt.Felt

func (Network) ChainIDString added in v0.4.0

func (n Network) ChainIDString() string

func (Network) CoreContractAddress added in v0.4.0

func (n Network) CoreContractAddress() (common.Address, error)

func (Network) DefaultL1ChainID added in v0.4.0

func (n Network) DefaultL1ChainID() *big.Int

func (Network) FeederURL added in v0.4.0

func (n Network) FeederURL() string

FeederURL returns URL for read commands

func (Network) GatewayURL added in v0.4.0

func (n Network) GatewayURL() string

GatewayURL returns URL for write commands

func (*Network) MarshalJSON added in v0.6.0

func (n *Network) MarshalJSON() ([]byte, error)

func (Network) MarshalYAML added in v0.6.0

func (n Network) MarshalYAML() (interface{}, error)

func (Network) ProtocolID added in v0.6.0

func (n Network) ProtocolID() protocol.ID

func (*Network) Set added in v0.2.1

func (n *Network) Set(s string) error

func (Network) String

func (n Network) String() string

func (*Network) Type added in v0.2.1

func (n *Network) Type() string

func (*Network) UnmarshalText added in v0.2.1

func (n *Network) UnmarshalText(text []byte) error

type SimpleLogger

type SimpleLogger interface {
	Debugw(msg string, keysAndValues ...any)
	Infow(msg string, keysAndValues ...any)
	Warnw(msg string, keysAndValues ...any)
	Errorw(msg string, keysAndValues ...any)
}

type Throttler added in v0.7.4

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

func NewThrottler added in v0.7.4

func NewThrottler[T any](concurrencyBudget uint, resource *T) *Throttler[T]

func (*Throttler[T]) Do added in v0.7.4

func (t *Throttler[T]) Do(doer func(resource *T) error) error

Do lets caller acquire the resource within the context of a callback

func (*Throttler[T]) QueueLen added in v0.7.4

func (t *Throttler[T]) QueueLen() int

QueueLen returns the number of Do calls that is blocked on the resource

func (*Throttler[T]) WithMaxQueueLen added in v0.7.4

func (t *Throttler[T]) WithMaxQueueLen(maxQueueLen int32) *Throttler[T]

WithMaxQueueLen sets the maximum length the queue can grow to

type ZapLogger

type ZapLogger struct {
	*zap.SugaredLogger
}

func NewNopZapLogger

func NewNopZapLogger() *ZapLogger

func NewZapLogger

func NewZapLogger(logLevel LogLevel, colour bool) (*ZapLogger, error)

func (*ZapLogger) Warningf

func (l *ZapLogger) Warningf(msg string, args ...any)

Jump to

Keyboard shortcuts

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