common

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 5 Imported by: 0

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 ItemsStreamGrouped added in v1.7.0

type ItemsStreamGrouped 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

func (*Lister) GetGrouped added in v1.7.0

func (p *Lister) GetGrouped(ctx context.Context, filters map[string]interface{}, groupSize int) ItemsStreamGrouped

func (*Lister) SetRequestThrottler added in v1.7.5

func (p *Lister) SetRequestThrottler(thrl Throttler)

SetRequestThrottler concurrent unsafe setter, call it before calling any Get or GetGrouped method

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