activity

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate

func Paginate(ctx context.Context, paginator Paginator, spec Pagination) error

Types

type Export

type Export struct {
	*File
	ID int64 `json:"id"`
}

Export the contents and metadata about an activity file

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:"-"`
	FQPN      string `json:"fqpn,omitempty"`
	Name      string `json:"name"`
	Format    Format `json:"format"`
}

File for uploading and exporting

func (*File) Close

func (f *File) Close() error

Close the reader (if supported)

type Format

type Format int

Format of the file used in exporting and uploading

const (
	// Original format (essentially a wildcard)
	Original Format = iota // original
	// GPX format
	GPX // gpx
	// TCX format
	TCX // tcx
	// FIT format
	FIT // fit
)

func ToFormat

func ToFormat(format string) Format

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

func (f *Format) MarshalJSON() ([]byte, error)

MarshalJSON converts a Format enum to a string representation

func (Format) String

func (i Format) String() string

type Named

type Named struct {
	ID     int64     `json:"id"`
	Name   string    `json:"name"`
	Source string    `json:"source"`
	Date   time.Time `json:"date"`
}

A Named provides a minimal set of metadata about an entity

type Namer

type Namer interface {
	Named() *Named
}

A Namer returns a Named for an entity

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

type Upload

type Upload interface {
	// Identifier is unique id for the upload
	Identifier() UploadID
	// Done returns whether the upload is complete, either successfully or an error occurred
	Done() bool
}

Upload is the current status of an upload request

type UploadID

type UploadID int64

UploadID is the type for all upload identifiers

type Uploader

type Uploader interface {
	// Upload uploads a file
	Upload(ctx context.Context, file *File) (Upload, error)
	// Status returns the processing status of a file
	Status(ctx context.Context, id UploadID) (Upload, error)
}

Uploader supports uploading and status checking of an upload

Directories

Path Synopsis
web
Package web scrapes the strava website for functionality not available via the API.
Package web scrapes the strava website for functionality not available via the API.

Jump to

Keyboard shortcuts

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