rewards

package
v1.47.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPartners is the default error class for partners package.
	ErrPartners = errs.Class("partners")

	// ErrPartnerNotExist is returned when a particular partner does not exist.
	ErrPartnerNotExist = errs.Class("partner does not exist")
)
View Source
var DefaultPartnersDB = func() PartnersDB {
	list := DefaultPartners()
	db, err := NewPartnersStaticDB(&list)
	if err != nil {
		panic(err)
	}
	return db
}()

DefaultPartnersDB is current default settings.

Functions

func CanonicalUserAgentProduct added in v0.26.0

func CanonicalUserAgentProduct(product string) string

CanonicalUserAgentProduct returns canonicalizes the user agent product, which is suitable for lookups.

Types

type PartnerInfo added in v0.16.0

type PartnerInfo struct {
	Name string
	ID   string
	UUID uuid.UUID
}

PartnerInfo contains information about a partner.

func (*PartnerInfo) UserAgent added in v0.26.0

func (p *PartnerInfo) UserAgent() string

UserAgent returns canonical user agent.

type PartnerList added in v0.26.0

type PartnerList struct {
	Partners []PartnerInfo
}

PartnerList defines a json struct for defining partners.

func DefaultPartners added in v0.26.0

func DefaultPartners() PartnerList

DefaultPartners lists Storj default open-source partners.

func PartnersListFromJSONFile added in v0.26.0

func PartnersListFromJSONFile(path string) (*PartnerList, error)

PartnersListFromJSONFile loads a json definition of partners.

type PartnersDB added in v0.26.0

type PartnersDB interface {
	// All returns all partners.
	All(ctx context.Context) ([]PartnerInfo, error)
	// ByName returns partner definitions for a given name.
	ByName(ctx context.Context, name string) (PartnerInfo, error)
	// ByID returns partner definition corresponding to an id.
	ByID(ctx context.Context, id string) (PartnerInfo, error)
	// ByUserAgent returns partner definition corresponding to an user agent string.
	ByUserAgent(ctx context.Context, agent string) (PartnerInfo, error)
}

PartnersDB allows access to partners database.

architecture: Database

type PartnersService added in v0.26.0

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

PartnersService allows manipulating and accessing partner information.

architecture: Service

func NewPartnersService added in v0.26.0

func NewPartnersService(log *zap.Logger, db PartnersDB) *PartnersService

NewPartnersService returns a service for handling partner information.

func (*PartnersService) All added in v0.26.0

func (service *PartnersService) All(ctx context.Context) ([]PartnerInfo, error)

All returns all partners.

func (*PartnersService) ByName added in v0.27.0

func (service *PartnersService) ByName(ctx context.Context, name string) (PartnerInfo, error)

ByName looks up partner by name.

func (*PartnersService) ByUserAgent added in v0.27.0

func (service *PartnersService) ByUserAgent(ctx context.Context, userAgentString string) (PartnerInfo, error)

ByUserAgent looks up partner by user agent.

type PartnersStaticDB added in v0.26.0

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

PartnersStaticDB implements partner lookup based on a static definition.

architecture: Database Implementation

func NewPartnersStaticDB added in v0.26.0

func NewPartnersStaticDB(list *PartnerList) (*PartnersStaticDB, error)

NewPartnersStaticDB creates a new PartnersStaticDB.

func (*PartnersStaticDB) All added in v0.26.0

func (db *PartnersStaticDB) All(ctx context.Context) ([]PartnerInfo, error)

All returns all partners.

func (*PartnersStaticDB) ByID added in v0.26.0

func (db *PartnersStaticDB) ByID(ctx context.Context, id string) (PartnerInfo, error)

ByID returns partner definition corresponding to an id.

func (*PartnersStaticDB) ByName added in v0.26.0

func (db *PartnersStaticDB) ByName(ctx context.Context, name string) (PartnerInfo, error)

ByName returns partner definitions for a given name. Name is case insensitive.

func (*PartnersStaticDB) ByUserAgent added in v0.26.0

func (db *PartnersStaticDB) ByUserAgent(ctx context.Context, agent string) (PartnerInfo, error)

ByUserAgent returns partner definition corresponding to an user agent product string.

Jump to

Keyboard shortcuts

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