Documentation
¶
Index ¶
- Constants
- Variables
- func HashByte(data []byte) string
- func HashDatasourceInfo(dsInfo *backend.DataSourceInstanceSettings) string
- func HashString(text string) string
- type ActivityDTO
- type DSCache
- func (c *DSCache) Delete(request string)
- func (c *DSCache) Flush()
- func (c *DSCache) Get(request string) (interface{}, bool)
- func (c *DSCache) Load(request string) (string, error)
- func (c *DSCache) Save(request string, response interface{}) error
- func (c *DSCache) Set(request string, response interface{})
- func (c *DSCache) SetDefault(request string, response interface{})
- func (c *DSCache) SetWithExpiration(request string, response interface{}, d time.Duration)
- func (c *DSCache) SetWithNoExpiration(request string, response interface{})
- type PrefetchStreamTask
- type QueryModel
- type StravaAPIRequest
- type StravaApiResourceResponse
- type StravaAuthRequest
- type StravaAuthResourceResponse
- type StravaDatasourceInstance
- func (ds *StravaDatasourceInstance) ExchangeToken(authCode string) (*TokenExchangeResponse, error)
- func (ds *StravaDatasourceInstance) GetAccessToken() (string, error)
- func (ds *StravaDatasourceInstance) GetRefreshToken() (string, error)
- func (ds *StravaDatasourceInstance) RefreshAccessToken(refreshToken string) (*TokenExchangeResponse, error)
- func (ds *StravaDatasourceInstance) ResetAccessToken() error
- func (ds *StravaDatasourceInstance) ResetCache()
- func (ds *StravaDatasourceInstance) SaveRefreshToken(token string) error
- func (ds *StravaDatasourceInstance) StravaAPIQuery(ctx context.Context, query *StravaAPIRequest) (*StravaApiResourceResponse, error)
- func (ds *StravaDatasourceInstance) StravaAPIQueryWithCache(requestHash string) func(context.Context, *StravaAPIRequest) (*StravaApiResourceResponse, error)
- func (ds *StravaDatasourceInstance) StravaAuthQuery(ctx context.Context, req *StravaAuthRequest) (*StravaAuthResourceResponse, error)
- type StravaDatasourcePlugin
- func (ds *StravaDatasourcePlugin) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
- func (ds *StravaDatasourcePlugin) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
- func (ds *StravaDatasourcePlugin) ResetAccessTokenHandler(rw http.ResponseWriter, req *http.Request)
- func (ds *StravaDatasourcePlugin) ResetCacheHandler(rw http.ResponseWriter, req *http.Request)
- func (ds *StravaDatasourcePlugin) RootHandler(rw http.ResponseWriter, req *http.Request)
- func (ds *StravaDatasourcePlugin) StravaAPIHandler(rw http.ResponseWriter, req *http.Request)
- func (ds *StravaDatasourcePlugin) StravaAuthHandler(rw http.ResponseWriter, req *http.Request)
- type StravaDatasourceSettingsDTO
- type StravaPrefetcher
- func (p *StravaPrefetcher) GetActivities() ([]string, error)
- func (p *StravaPrefetcher) PrefetchActivities(activities []string)
- func (p *StravaPrefetcher) PrefetchActivitiesVariable(limit int)
- func (p *StravaPrefetcher) PrefetchActivity(activityId string)
- func (p *StravaPrefetcher) PrefetchActivityStreams(activityId string)
- func (p *StravaPrefetcher) Run()
- type TokenExchangeResponse
Constants ¶
const MaxTasks = 4
const StravaAPITokenUrl = "https://www.strava.com/api/v3/oauth/token"
const StravaAPIUrl = "https://www.strava.com/api/v3"
const StravaApiQueryType = "stravaAPI"
const StravaAuthQueryType = "stravaAuth"
Variables ¶
var ErrAlertingNotSupported = errors.New("alerting not supported")
Functions ¶
func HashDatasourceInfo ¶
func HashDatasourceInfo(dsInfo *backend.DataSourceInstanceSettings) string
HashDatasourceInfo converts the given datasource info to hash string
func HashString ¶
HashString converts the given text string to hash string
Types ¶
type ActivityDTO ¶ added in v1.5.0
type ActivityDTO = struct {
Id int64 `json:"id"`
}
type DSCache ¶
type DSCache struct {
// contains filtered or unexported fields
}
DSCache is a abstraction over go-cache.
func NewDSCache ¶
func NewDSCache(dsInfo *backend.DataSourceInstanceSettings, ttl time.Duration, cleanupInterval time.Duration, dataDir string) *DSCache
NewDSCache creates a go-cache with expiration(ttl) time and cleanupInterval.
func (*DSCache) Set ¶
Add an item to the cache with default expiration time, replacing any existing item.
func (*DSCache) SetDefault ¶
Set the value of the key "request" to "response" with default expiration time.
func (*DSCache) SetWithExpiration ¶ added in v1.5.0
Save item to the cache with provided expiration time
func (*DSCache) SetWithNoExpiration ¶ added in v1.5.0
Save item to the cache with no expiration
type PrefetchStreamTask ¶ added in v1.5.0
type PrefetchStreamTask struct {
// contains filtered or unexported fields
}
type QueryModel ¶
type QueryModel struct { QueryType string `json:"queryType"` ActivityStat string `json:"activityStat"` ActivityType string `json:"activityType"` Format string `json:"format"` Interval string `json:"interval"` // Direct from the gRPC interfaces TimeRange backend.TimeRange `json:"-"` }
QueryModel model
type StravaAPIRequest ¶
type StravaAPIRequest struct { Endpoint string `json:"endpoint"` Params map[string]json.RawMessage `json:"params,omitempty"` AccessToken string }
type StravaApiResourceResponse ¶
type StravaApiResourceResponse struct {
Result interface{} `json:"result,omitempty"`
}
func BuildAPIResponse ¶
func BuildAPIResponse(apiResponse []byte) (*StravaApiResourceResponse, error)
type StravaAuthRequest ¶
type StravaAuthRequest struct {
AuthCode string `json:"authCode"`
}
type StravaAuthResourceResponse ¶
type StravaAuthResourceResponse struct {
Result interface{} `json:"result,omitempty"`
}
type StravaDatasourceInstance ¶
type StravaDatasourceInstance struct {
// contains filtered or unexported fields
}
StravaDatasourceInstance stores state about a specific datasource and provides methods to make requests to the Strava API
func (*StravaDatasourceInstance) ExchangeToken ¶
func (ds *StravaDatasourceInstance) ExchangeToken(authCode string) (*TokenExchangeResponse, error)
ExchangeToken invokes first time when authentication required and exchange authorization code for the access and refresh tokens https://developers.strava.com/docs/authentication/#tokenexchange
func (*StravaDatasourceInstance) GetAccessToken ¶
func (ds *StravaDatasourceInstance) GetAccessToken() (string, error)
func (*StravaDatasourceInstance) GetRefreshToken ¶ added in v1.5.1
func (ds *StravaDatasourceInstance) GetRefreshToken() (string, error)
func (*StravaDatasourceInstance) RefreshAccessToken ¶
func (ds *StravaDatasourceInstance) RefreshAccessToken(refreshToken string) (*TokenExchangeResponse, error)
RefreshAccessToken refreshes expired Access token using refresh token https://developers.strava.com/docs/authentication/#refreshingexpiredaccesstokens
func (*StravaDatasourceInstance) ResetAccessToken ¶ added in v1.4.0
func (ds *StravaDatasourceInstance) ResetAccessToken() error
func (*StravaDatasourceInstance) ResetCache ¶ added in v1.5.0
func (ds *StravaDatasourceInstance) ResetCache()
func (*StravaDatasourceInstance) SaveRefreshToken ¶ added in v1.7.0
func (ds *StravaDatasourceInstance) SaveRefreshToken(token string) error
SaveRefreshToken saves refresh token in secureJsonData by calling update data source API endpoint
func (*StravaDatasourceInstance) StravaAPIQuery ¶
func (ds *StravaDatasourceInstance) StravaAPIQuery(ctx context.Context, query *StravaAPIRequest) (*StravaApiResourceResponse, error)
func (*StravaDatasourceInstance) StravaAPIQueryWithCache ¶ added in v1.5.0
func (ds *StravaDatasourceInstance) StravaAPIQueryWithCache(requestHash string) func(context.Context, *StravaAPIRequest) (*StravaApiResourceResponse, error)
func (*StravaDatasourceInstance) StravaAuthQuery ¶
func (ds *StravaDatasourceInstance) StravaAuthQuery(ctx context.Context, req *StravaAuthRequest) (*StravaAuthResourceResponse, error)
type StravaDatasourcePlugin ¶ added in v1.7.0
type StravaDatasourcePlugin struct {
// contains filtered or unexported fields
}
func NewStravaDatasourcePlugin ¶ added in v1.7.0
func NewStravaDatasourcePlugin(dataDir string, saToken string) *StravaDatasourcePlugin
func (*StravaDatasourcePlugin) CheckHealth ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
CheckHealth checks if the plugin is running properly
func (*StravaDatasourcePlugin) QueryData ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
func (*StravaDatasourcePlugin) ResetAccessTokenHandler ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) ResetAccessTokenHandler(rw http.ResponseWriter, req *http.Request)
func (*StravaDatasourcePlugin) ResetCacheHandler ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) ResetCacheHandler(rw http.ResponseWriter, req *http.Request)
func (*StravaDatasourcePlugin) RootHandler ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) RootHandler(rw http.ResponseWriter, req *http.Request)
func (*StravaDatasourcePlugin) StravaAPIHandler ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) StravaAPIHandler(rw http.ResponseWriter, req *http.Request)
func (*StravaDatasourcePlugin) StravaAuthHandler ¶ added in v1.7.0
func (ds *StravaDatasourcePlugin) StravaAuthHandler(rw http.ResponseWriter, req *http.Request)
type StravaDatasourceSettingsDTO ¶ added in v1.5.0
type StravaPrefetcher ¶ added in v1.5.0
type StravaPrefetcher struct {
// contains filtered or unexported fields
}
func NewStravaPrefetcher ¶ added in v1.5.0
func NewStravaPrefetcher(depth int, ds *StravaDatasourceInstance) *StravaPrefetcher
func (*StravaPrefetcher) GetActivities ¶ added in v1.5.0
func (p *StravaPrefetcher) GetActivities() ([]string, error)
func (*StravaPrefetcher) PrefetchActivities ¶ added in v1.5.0
func (p *StravaPrefetcher) PrefetchActivities(activities []string)
func (*StravaPrefetcher) PrefetchActivitiesVariable ¶ added in v1.5.0
func (p *StravaPrefetcher) PrefetchActivitiesVariable(limit int)
func (*StravaPrefetcher) PrefetchActivity ¶ added in v1.5.0
func (p *StravaPrefetcher) PrefetchActivity(activityId string)
func (*StravaPrefetcher) PrefetchActivityStreams ¶ added in v1.5.0
func (p *StravaPrefetcher) PrefetchActivityStreams(activityId string)
func (*StravaPrefetcher) Run ¶ added in v1.5.0
func (p *StravaPrefetcher) Run()
Run starts background prefetcher task