datasource

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: Apache-2.0 Imports: 4 Imported by: 152

Documentation

Overview

Package datasource provides utilities for data source plugins.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryTypeHandlerFunc

type QueryTypeHandlerFunc func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)

QueryTypeHandlerFunc is an adapter to allow the use of ordinary functions as backend.QueryDataHandler. If f is a function with the appropriate signature, QueryTypeHandlerFunc(f) is a Handler that calls f.

func (QueryTypeHandlerFunc) QueryData

QueryData calls f(ctx, req).

type QueryTypeMux

type QueryTypeMux struct {
	// contains filtered or unexported fields
}

QueryTypeMux is a query type multiplexer.

Example
mux := NewQueryTypeMux()
mux.HandleFunc("queryTypeA", func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
	// handle queryTypeA
	return nil, nil
})
mux.HandleFunc("queryTypeB", func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
	// handle queryTypeB
	return nil, nil
})

_ = backend.ServeOpts{
	QueryDataHandler: mux,
}

func NewQueryTypeMux

func NewQueryTypeMux() *QueryTypeMux

NewQueryTypeMux allocates and returns a new QueryTypeMux.

func (*QueryTypeMux) Handle

func (mux *QueryTypeMux) Handle(queryType string, handler backend.QueryDataHandler)

Handle registers the handler for the given query type.

Providing an empty queryType registers the handler as a fallback handler that will be called when query type doesn't match any registered handlers. If handler is nil, Handle panics. If a handler already exists for queryType, Handle panics.

func (*QueryTypeMux) HandleFunc

func (mux *QueryTypeMux) HandleFunc(queryType string, handler func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error))

HandleFunc registers the handler function for the given query type.

Providing an empty queryType registers the handler as a fallback handler that will be called when query type doesn't match any registered handlers. If handler is nil, Handle panics. If a handler already exists for queryType, Handle panics.

func (*QueryTypeMux) QueryData

QueryData dispatches the request to the handler(s) whose query type matches the request queries query type.

Jump to

Keyboard shortcuts

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