Documentation
¶
Index ¶
Constants ¶
const DefaultAddr = "api.zvelo.com"
DefaultAddr is used by both GRPCv1Client and RESTv1Client as the default address:port for all zveloAPI calls. It can be overridden using the WithAddr Option.
const DefaultScopes = "zvelo.dataset"
DefaultScopes are the default scopes used when no scopes are explicietly defined
const UserAgent = "go-zapi v1"
UserAgent is the user agent that will be provided by the RESTv1Client. It can be overridden by providing a custom transport using the WithTransport Option.
Variables ¶
var Endpoint = oauth2.Endpoint{
AuthURL: "https://auth.zvelo.com/oauth2/auth",
TokenURL: "https://auth.zvelo.com/oauth2/token",
}
Endpoint is an oauth2.Endpoint that is useful for working with the oauth2 package
Functions ¶
This section is empty.
Types ¶
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption configures a Call before it starts or extracts information from a Call after it completes. It is only used with the RESTv1Client. grpc.CallOption is still available for the GRPCv1Client.
func Response ¶
func Response(h **http.Response) CallOption
Response will return the entire http.Response received from a zveloAPI call. This is useful to request or response headers, see http error messages, read the raw body and more.
type GRPCv1Client ¶
type GRPCv1Client interface { msg.APIv1Client io.Closer }
A GRPCv1Client implements msg.APIv1Client as well as an io.Closer that, if closed, will close the underlying gRPC connection.
type GRPCv1Dialer ¶
type GRPCv1Dialer interface {
Dial(context.Context, ...grpc.DialOption) (GRPCv1Client, error)
}
A GRPCv1Dialer is used to simplify connecting to zveloAPI with the correct options. grpc DialOptions will override the defaults.
func NewGRPCv1 ¶
func NewGRPCv1(ts oauth2.TokenSource, opts ...Option) GRPCv1Dialer
NewGRPCv1 returns a properly configured GRPCv1Dialer
type Option ¶
type Option func(*options)
An Option is used to configure different parts of this package. Not every Option is useful with every function that takes Options.
func WithAddr ¶
WithAddr returns an Option that overrides the default address:port for all zveloAPI requests
func WithDebug ¶
WithDebug returns an Option that will cause requests from the RESTv1Client and callbacks processed by the CallbackHandler to emit debug logs to the writer
func WithForceTrace ¶
func WithForceTrace() Option
WithForceTrace returns an Option that will cause all requests to be traced by the api server
func WithTLSInsecureSkipVerify ¶
func WithTLSInsecureSkipVerify() Option
WithTLSInsecureSkipVerify returns an Option that disables certificate chain and host name verification of the connection to zveloAPI. This should only be used for testing, e.g. with mocks.
func WithTracer ¶
func WithTracer(val opentracing.Tracer) Option
WithTracer returns an Option that will cause requests to be instrumented by the given tracer. If not specified, opentracing.GlobalTracer will be used.
func WithTransport ¶
func WithTransport(val http.RoundTripper) Option
WithTransport returns an Option that will cause all requests from the RESTv1Client to be processed by the given http.RoundTripper. If not specified, http.DefaultTransport will be used.
type RESTv1Client ¶
type RESTv1Client interface { Query(ctx context.Context, in *msg.QueryRequests, opts ...CallOption) (*msg.QueryReplies, error) Result(ctx context.Context, reqID string, opts ...CallOption) (*msg.QueryResult, error) GraphQL(ctx context.Context, query string, result interface{}, opts ...CallOption) error Suggest(ctx context.Context, in *msg.Suggestion, opts ...CallOption) error Stream(ctx context.Context) (RESTv1StreamClient, error) }
A RESTv1Client implements a very similar interface to GRPCv1Client but uses a standard HTTP/REST transport instead of gRPC. Generally the gRPC client is preferred for its efficiency.
func NewRESTv1 ¶
func NewRESTv1(ts oauth2.TokenSource, opts ...Option) RESTv1Client
NewRESTv1 returns a properly configured RESTv1Client
type RESTv1StreamClient ¶ added in v1.6.0
type RESTv1StreamClient interface {
Recv() (*msg.QueryResult, error)
}
RESTv1StreamClient provides an interface to receive streamed query results from zveloAPI servers.