Documentation ¶
Index ¶
- Constants
- Variables
- func NewPulsarDatasource(_ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error)
- type App
- type GetAppsResponse
- type Job
- type PulsarAppParameter
- type PulsarAppParameters
- type PulsarClient
- func (pc *PulsarClient) CheckAPIKey(apiKey string) error
- func (pc *PulsarClient) GetApps(apiKey string, params ...PulsarAppParameter) (*GetAppsResponse, error)
- func (pc *PulsarClient) GetData(apiKey string, query *queryModel) ([]time.Time, []float64, error)
- func (pc *PulsarClient) GetJobs(apiKey, appID string, params ...PulsarAppParameter) ([]Job, error)
- type PulsarData
- type PulsarDatasource
Constants ¶
const (
// APIKey is the key to get the NS1 API Key from the decrypted secure data.
APIKey = "apiKey"
)
Variables ¶
var Logger = log.DefaultLogger
Functions ¶
func NewPulsarDatasource ¶
func NewPulsarDatasource(_ backend.DataSourceInstanceSettings) (instancemgmt.Instance, error)
NewPulsarDatasource creates a new datasource instance.
Types ¶
type App ¶
type App struct { AppID string `json:"appid"` Name string `json:"name,omitempty"` Jobs []Job `json:"jobs"` }
App is a basic model to exchange information with the frontend.
type GetAppsResponse ¶
GetAppsResponse holds the App and Job info in two formats: A slice to be conveyed to the UI and a couple of maps for internal caching.
type PulsarAppParameter ¶
type PulsarAppParameter func(p *PulsarAppParameters)
func OptionAppFetchJobs ¶
func OptionAppFetchJobs(fetchJobs bool) PulsarAppParameter
OptionAppFetchJobs indicates the GetApp function to retrieve the Job list for each Pulsar App.
func OptionJobsFetchInactive ¶
func OptionJobsFetchInactive(fetchInactive bool) PulsarAppParameter
OptionJobsFetchInactive indicates that the API must also retrieve jobs marked as inactive along with active ones.
func PulsarAppFetchInactive ¶
func PulsarAppFetchInactive(fetchInactive bool) PulsarAppParameter
PulsarAppFetchInactive indicates the GetApp function to retrieve Apps marked as Inactive.
type PulsarAppParameters ¶
PulsarAppParameters are all the options available to retrieve Apps and Jobs. The options are dynamically provided.
type PulsarClient ¶
type PulsarClient struct {
// contains filtered or unexported fields
}
PulsarClient is the main Object and contain the implementation of the Query Logic.
func NewPulsarClient ¶
func NewPulsarClient() *PulsarClient
NewPulsarClient is the default constructor for the Pulsar Client object.
func (*PulsarClient) CheckAPIKey ¶
func (pc *PulsarClient) CheckAPIKey(apiKey string) error
CheckAPIKey verifies the provided API key against the NS1 API. It returns error if the key is invalid, meaning that the authorization was denied.
func (*PulsarClient) GetApps ¶
func (pc *PulsarClient) GetApps(apiKey string, params ...PulsarAppParameter) (*GetAppsResponse, error)
GetApps query the NS1 API and retrieves the Pulsar Apps and optionally their Pulsar Jobs.
func (*PulsarClient) GetData ¶
GetData queries the NS1 API to fetch the performance or availability data. It requires the actual query string and an instance of the queryModel. Returns 3 values:
- A slice of times. This is passed to the Frame.
- A slice of values. This is passed to the Frame.
- An error if something goes wrong.
func (*PulsarClient) GetJobs ¶
func (pc *PulsarClient) GetJobs(apiKey, appID string, params ...PulsarAppParameter) ([]Job, error)
GetJobs retrieves a Job slice given the appID.
type PulsarData ¶
type PulsarData struct {
// contains filtered or unexported fields
}
PulsarData is the data struct for caching Apps and Jobs. Given that the plugin instance can use only one API Key, these values will be the same for any user of the plugin. The ttl field it's expressed in seconds.
func NewPulsarData ¶
func NewPulsarData(appsResponse *GetAppsResponse, ttl time.Duration) *PulsarData
NewPulsarData is the constructor for the Pulsar Data (apps and jobs).
type PulsarDatasource ¶
type PulsarDatasource struct {
// contains filtered or unexported fields
}
PulsarDatasource is an example datasource which can respond to data queries, reports its health and has streaming skills.
func (*PulsarDatasource) CheckHealth ¶
func (p *PulsarDatasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
CheckHealth handles health checks sent from Grafana to the plugin. The main use case for these health checks is the test button on the datasource configuration page which allows users to verify that a datasource is working as expected.
func (*PulsarDatasource) Dispose ¶
func (p *PulsarDatasource) Dispose()
Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance created. As soon as datasource settings change detected by SDK old datasource instance will be disposed and a new one will be created using NewPulsarDatasource factory function.
func (*PulsarDatasource) QueryData ¶
func (p *PulsarDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
QueryData handles multiple queries and returns multiple responses. req contains the queries []DataQuery (where each query contains RefID as a unique identifier). The QueryDataResponse contains a map of RefID to the response for each query, and each response contains Frames ([]*Frame).