Documentation ¶
Index ¶
- Constants
- Variables
- func Decode[T any](reader io.Reader) (*T, error)
- func FunctionRetrier[T any](ctx context.Context, fn func() (T, error)) (result T, err error)
- func Unmarshal[T any](data []byte) (*T, error)
- func ValidateField(f interface{}, tag string) error
- func ValidateStruct(s interface{}) error
- type ContextKey
- type Header
- type HttpClient
- type HttpOptions
- type LogEvent
- type Logger
- type Settings
- type SigninMessage
- type Stream
- type VoteMessage
- type VoteType
- type VoteValue
Constants ¶
View Source
const MAX_RETRIES float64 = 4
Variables ¶
View Source
var ( ContextKeyTraceID = ContextKey("request id") ContextKeyRequestStartTime = ContextKey("request start time") ContextKeyRemoteAddress = ContextKey("request remote address") ContextKeyUser = ContextKey("user") )
Functions ¶
func FunctionRetrier ¶
Invoke a function with exponential backoff when a retryable error is encountered. If fn returns an err that is wrapped in common.ErrRetyable, fn will be retried with exponential backoff. This was originally implemented to solve getting rate limited by the alchemy APIs
See: https://docs.alchemy.com/alchemy/documentation/rate-limits#retries
func ValidateField ¶
func ValidateStruct ¶
func ValidateStruct(s interface{}) error
Types ¶
type ContextKey ¶
type ContextKey string
func (ContextKey) String ¶
func (c ContextKey) String() string
type HttpClient ¶
type HttpClient interface {
Do(ctx context.Context, method string, url string, body io.Reader, options *HttpOptions) (*http.Response, error)
}
func NewHttpClient ¶
func NewHttpClient(logger Logger) HttpClient
type HttpOptions ¶
type HttpOptions struct {
Headers []Header
}
type Logger ¶
type Settings ¶
These are intended to be generic settings that every app is expected to implement. packages in common can safely expect to have access to these settings in their constructors.
func NewSettings ¶
func NewSettings() Settings
type SigninMessage ¶
type SigninMessage struct {
Address string `json:"address"`
}
type VoteMessage ¶
Click to show internal directories.
Click to hide internal directories.