eax

package
v0.0.0-...-8e88d4a Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package eax queries the EA App API.

Index

Constants

This section is empty.

Variables

View Source
var ErrAutoUpdateBackoff = errors.New("not updating eax client version due to backoff")
View Source
var ErrVersionRequired = errors.New("client version is required for this endpoint")

Functions

This section is empty.

Types

type Client

type Client struct {
	// The [net/http.Client] to use for requests. If not provided,
	// [net/http.DefaultClient] is used.
	Client *http.Client

	// The UpdateMgr for requests which require version information.
	UpdateMgr *UpdateMgr
}

func (*Client) PlayerIDByPD

func (c *Client) PlayerIDByPD(ctx context.Context, pd uint64) (*PlayerID, error)

PlayerByPd gets basic information about an Origin ID. If the player does not exist, nil will be returned.

type PlayerID

type PlayerID struct {
	PD          uint64 // origin ID
	PSD         uint64 // ?
	DisplayName string // in-game name
	Nickname    string // social name?
}

PlayerID contains basic identifiers and names for a player.

type UpdateMgr

type UpdateMgr struct {
	// HTTP client to use. If not provided, [net/http.DefaultClient] will be
	// used.
	Client *http.Client

	// Timeout is the timeout for refreshing tokens. If zero, a reasonable
	// default is used. If negative, there is no timeout.
	Timeout time.Duration

	// Interval to update at. If zero, will not auto-update.
	AutoUpdateInterval time.Duration

	// Auto-update staged roll-out bucket.
	AutoUpdateBucket int

	// Auto-update backoff, if provided, checks if another auto-update is
	// allowed after a failure. If it returns false, ErrAutoUpdateBackoff will be
	// returned from the function triggering the auto-update.
	AutoUpdateBackoff func(err error, time time.Time, count int) bool

	// AutoUpdateHook is called for every auto-update attempt with the new (or
	// current if error) version, and any error which occurred.
	AutoUpdateHook func(v string, err error)
	// contains filtered or unexported fields
}

UpdateMgr manages EAX client version information.

func (*UpdateMgr) SetVersion

func (u *UpdateMgr) SetVersion(v string)

SetVersion sets the current version.

func (*UpdateMgr) Update

func (u *UpdateMgr) Update(force bool) (string, bool, error)

Update gets the latest version, following u.AutoUpdateInterval if provided, unless the version is not set or force is true. If another update is in progress, it waits for the result of it. True is returned (on success or failure) if this call performed a update. This function may block for up to Timeout.

Jump to

Keyboard shortcuts

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