client

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT Imports: 20 Imported by: 0

README

Payyo SDK client for Go

Check out API documentation on developers.payyo.ch

Client

The client provides methods to call the Payyo API method with arbitrary parameters

Documentation

Index

Constants

View Source
const (
	// BaseURLV3 is base url for API version 3
	BaseURLV3 = "https://api.client.ch/v3"
)

Variables

This section is empty.

Functions

func ExponentialJitterBackoff

func ExponentialJitterBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration

ExponentialJitterBackoff returns exponential backoff with jitter seep = rand(minDelay, min(maxDelay, base * 2 ** attemptNum))

func Hmac256Signer

func Hmac256Signer(publicKey, secret string, body []byte) (string, error)

Hmac256Signer is default request signer

func LinearJitterBackoff

func LinearJitterBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration

LinearJitterBackoff linearly increased the backoff with jitter

Types

type Backoff

type Backoff func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration

Backoff allows to define different backoff scenarios to request retries

type Client

type Client interface {
	Call(method string, params, result interface{}) error
	CallWithContext(ctx context.Context, method string, params, result interface{}) error
}

Client is provided methods to all API

func New

func New(config *Config) Client

New creates a new client instance

type Config

type Config struct {
	BaseURL      string
	Logger       Logger
	RetryWaitMin time.Duration // Minimum time to wait
	RetryWaitMax time.Duration // Maximum time to wait
	RetryMax     int           // Maximum number of retries
	// contains filtered or unexported fields
}

Config is client configuration object

func NewConfig

func NewConfig(publicKey, secret string) *Config

NewConfig initializes a client configuration

type LogLevel

type LogLevel uint32

LogLevel specifies the logger log level

const (
	// ErrorLevel level. Used for errors that should definitely be noted.
	ErrorLevel LogLevel = iota
	// WarningLevel level. Non-critical entries.
	WarningLevel
	// InfoLevel level
	InfoLevel
	// DebugLevel level. Very verbose logging.
	DebugLevel
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Logf(level LogLevel, format string, args ...interface{})
}

Logger interfaces defines minimalistic interface to log messages

func NewDefaultLogger

func NewDefaultLogger(level LogLevel) Logger

NewDefaultLogger returns a Logger which will write log messages to stdout

func NewNullLogger

func NewNullLogger() Logger

NewNullLogger returns a Logger which prevents logging of unnecessary messages

type LoggerFunc

type LoggerFunc func(level LogLevel, format string, args ...interface{})

LoggerFunc provides a convenient way to wrap any function to Logger interface

func (LoggerFunc) Logf

func (f LoggerFunc) Logf(level LogLevel, format string, args ...interface{})

Logf calls the wrapped function with the arguments provided

type Signer

type Signer func(publicKey, secret string, body []byte) (string, error)

Signer is an interface of function to sign request body

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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