common

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxBulkRequestsCount       = 100
	MaxCountPerBulkRequestItem = 100
)
View Source
const DefaultMaxFetchersCount = 1
View Source
const DefaultMaxRequestsCountPerSecond = 0

Variables

This section is empty.

Functions

func CeilDivisionInt added in v1.6.1

func CeilDivisionInt(x, y int) int

Types

type Address added in v1.4.0

type Address struct {
	AddressID  int         `json:"addressID"`
	OwnerID    int         `json:"ownerID"`
	TypeID     interface{} `json:"typeID"`
	Address2   string      `json:"address2"`
	Address    string      `json:"address"`
	Street     string      `json:"street"`
	PostalCode string      `json:"postalCode"`
	City       string      `json:"city"`
	State      string      `json:"state"`
	Country    string      `json:"country"`
}

Address from getAddresses

type Addresses added in v1.4.0

type Addresses []Address

Addresses from getAddresses

type Cursor added in v1.6.1

type Cursor struct {
	Limit  int
	Offset int
}

type DataProvider added in v1.6.1

type DataProvider interface {
	Count(ctx context.Context, filters map[string]interface{}) (int, error)
	Read(ctx context.Context, bulkFilters []map[string]interface{}, callback func(item interface{})) error
}

type Item added in v1.6.1

type Item struct {
	Err        error
	TotalCount int
	Payload    interface{}
}

type ItemsStream added in v1.6.1

type ItemsStream chan Item

type Lister added in v1.6.1

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

func NewLister added in v1.6.1

func NewLister(settings ListingSettings, dataProvider DataProvider, sl Sleeper) *Lister

func (*Lister) Get added in v1.6.1

func (p *Lister) Get(ctx context.Context, filters map[string]interface{}) ItemsStream

type ListingSettings added in v1.6.1

type ListingSettings struct {
	MaxRequestsCountPerSecond int
	StreamBufferLength        int
	MaxFetchersCount          int
	MaxItemsPerRequest        int
}

type ObjAttribute added in v1.4.0

type ObjAttribute struct {
	AttributeName  string `json:"attributeName"`
	AttributeType  string `json:"attributeType"`
	AttributeValue string `json:"attributeValue"`
}

type SleepThrottler added in v1.6.1

type SleepThrottler struct {
	LimitPerSecond int
	LastTimestamp  int64
	Count          int
	// contains filtered or unexported fields
}

SleepThrottler implements sleeping logic for requests throttling

func NewSleepThrottler added in v1.6.1

func NewSleepThrottler(limitPerSecond int, sl Sleeper) *SleepThrottler

NewSleepThrottler creates SleepThrottler

func (*SleepThrottler) Throttle added in v1.6.1

func (rt *SleepThrottler) Throttle()

Throttle implements throttling method

type Sleeper added in v1.6.1

type Sleeper func(sleepTime time.Duration)

type Status

type Status struct {
	Request           string          `json:"request"`
	RequestUnixTime   int             `json:"requestUnixTime"`
	ResponseStatus    string          `json:"responseStatus"`
	ErrorCode         errors.ApiError `json:"errorCode"`
	ErrorField        string          `json:"errorField"`
	GenerationTime    float64         `json:"generationTime"`
	RecordsTotal      int             `json:"recordsTotal"`
	RecordsInResponse int             `json:"recordsInResponse"`
}

type StatusBulk

type StatusBulk struct {
	RequestName string `json:"requestName"`
	RequestID   string `json:"requestID"`
	Status
}

type Throttler added in v1.6.1

type Throttler interface {
	Throttle()
}

Throttler abstracts limiting of API requests

type ThrottlerMock added in v1.6.1

type ThrottlerMock struct {
	WasTriggered bool
}

func (*ThrottlerMock) Throttle added in v1.6.1

func (tm *ThrottlerMock) Throttle()

Jump to

Keyboard shortcuts

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