Documentation ¶
Index ¶
Constants ¶
const UserAgent = "github.com/bzimmer/activity"
Variables ¶
var ErrExceededIterations = errors.New("exceeded iterations")
Functions ¶
Types ¶
type Exporter ¶
type Exporter interface { // Export exports the data file Export(ctx context.Context, activityID int64) (*Export, error) }
Exporter exports activity data by activity id
type File ¶
type File struct { io.Reader `json:"-"` Filename string `json:"filename,omitempty"` Name string `json:"name"` Format Format `json:"format"` }
File for uploading and exporting
type Format ¶
type Format int
Format of the file used in exporting and uploading
func ToFormat ¶
ToFormat converts a file extension (with or without the ".") to a Format If no predefined extension exists the Format Original is returned
func (Format) MarshalJSON ¶
MarshalJSON converts a Format enum to a string representation
type GPXEncoder ¶ added in v0.6.0
type GPXEncoder interface { // GPX returns a GPX instance GPX() (*gpx.GPX, error) }
type Pagination ¶
type Pagination struct { // Total number of resources to query Total int // Start querying at this page Start int // Count of the number of resources to query per page Count int }
Pagination specifies how to paginate through resources
type Paginator ¶
type Paginator interface { // PageSize returns the number of resources to query per request PageSize() int // Count of the aggregate total of resources queried Count() int // Do executes the query using the pagination specification returning // the number of resources returned in this request or an error Do(ctx context.Context, spec Pagination) (int, error) }
Paginator paginates through results
type Poll ¶
type Poll struct { // Upload is the upload status if no error occurred Upload Upload // Err is non-nil when an error occurred in the operation but not semantically // Check the `Upload` for semantic errors (eg missing data, duplicate activity, ...) Err error }
Poll is the result of polling
type Poller ¶
type Poller interface { // Poll the status of an upload // // The operation will continue until either it is completed, the context // is canceled, or the maximum number of iterations have been exceeded. Poll(ctx context.Context, uploadID UploadID) <-chan *Poll }
Poller will continually check the status of an upload request
func NewPoller ¶
func NewPoller(uploader Uploader, opts ...PollerOption) Poller
NewPoller returns an instance of a Poller
type PollerOption ¶
type PollerOption func(p *poller)
A PollerOption allows configuring the default poller
func WithInterval ¶
func WithInterval(interval time.Duration) PollerOption
WithInterval controls the duration between status polling
func WithIterations ¶
func WithIterations(iterations int) PollerOption
WithIterations controls the max number of polling iterations