Documentation
¶
Index ¶
- Constants
- Variables
- func FixupEndpointURLScheme(u string) string
- func HasAsyncID(ctx context.Context) (string, bool)
- func IsAsyncJobInProgress(err error) (string, bool)
- func IsAsyncRequest(ctx context.Context) bool
- func IsCodeError(err error, code int) bool
- func IsNotFoundError(err error) bool
- func NewError(code int, message string) error
- func NewErrorf(code int, message string, args ...interface{}) error
- func NewHTTP2DialForEndpoint(e Endpoint) func(network, addr string, cfg *tls.Config) (net.Conn, error)
- func NewNotFoundError(msg string) error
- func NewUrl(parts ...string) string
- func RequestDBNameValueExtractor(requestMethod, requestPath string) (string, error)
- func WithArangoQueueTime(parent context.Context, duration time.Duration) context.Context
- func WithArangoQueueTimeout(parent context.Context, useQueueTimeout bool) context.Context
- func WithAsync(parent context.Context) context.Context
- func WithAsyncID(parent context.Context, asyncID string) context.Context
- func WithDriverFlags(parent context.Context, value []string) context.Context
- type Array
- type AsyncConnectionWrapper
- type Authentication
- type AuthenticationGetter
- type Connection
- func NewConnectionAsyncWrapper(conn Connection) Connection
- func NewHttp2Connection(config Http2Configuration) Connection
- func NewHttpConnection(config HttpConfiguration) Connection
- func NewPool(connections int, factory Factory) (Connection, error)
- func NewRetryWrapper(conn Connection, retries int, wrapper RetryWrapper) Connection
- func RetryOn503(conn Connection, retries int) Connection
- type ContextKey
- type Decoder
- type Endpoint
- type Error
- type ErrorAsyncJobInProgress
- type Factory
- type Http2Configuration
- type HttpConfiguration
- type Request
- type RequestHashValueExtractor
- type RequestModifier
- type Response
- func Call(ctx context.Context, c Connection, method, url string, output interface{}, ...) (Response, error)
- func CallDelete(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallGet(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallHead(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallPatch(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallPost(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallPut(ctx context.Context, c Connection, url string, output interface{}, ...) (Response, error)
- func CallStream(ctx context.Context, c Connection, method, url string, ...) (Response, io.ReadCloser, error)
- func CallWithChecks(ctx context.Context, c Connection, method, url string, output interface{}, ...) (Response, error)
- type RetryWrapper
- type Wrapper
Constants ¶
const ( PlainText = "text/plain" ApplicationOctetStream = "application/octet-stream" ApplicationZip = "application/zip" )
const ( ArangoHeaderAsyncIDKey = "x-arango-async-id" ArangoHeaderAsyncKey = "x-arango-async" ArangoHeaderAsyncValue = "store" )
const (
ApplicationJSON = "application/json"
)
const (
ApplicationVPack = "application/x-velocypack"
)
const (
ContentType = "content-type"
)
Variables ¶
var ErrReaderOutputBytes = errors.New("use *[]byte as output argument")
ErrReaderOutputBytes is the error to inform caller about invalid output argument.
var ErrWriterInputBytes = errors.New("use []byte as input argument")
ErrWriterInputBytes is the error to inform caller about invalid input argument.
Functions ¶
func FixupEndpointURLScheme ¶
FixupEndpointURLScheme changes endpoint URL schemes used by arangod to ones used by go. E.g. "tcp://localhost:8529" -> "http://localhost:8529"
func HasAsyncID ¶ added in v2.0.3
HasAsyncID returns the async Job ID from the given context.
func IsAsyncJobInProgress ¶ added in v2.0.3
func IsAsyncRequest ¶ added in v2.0.3
IsAsyncRequest returns true if the given context is an async request.
func IsCodeError ¶
func IsNotFoundError ¶
func NewHTTP2DialForEndpoint ¶
func NewNotFoundError ¶
func RequestDBNameValueExtractor ¶ added in v2.0.3
RequestDBNameValueExtractor might be used as RequestHashValueExtractor to use DB name from URL for hashing It fallbacks to requestMethod+requestPath concatenation in case if path does not contain DB name
func WithArangoQueueTime ¶
WithArangoQueueTime defines max queue timeout on the server side.
func WithArangoQueueTimeout ¶
WithArangoQueueTimeout is used to enable Queue timeout on the server side. If WithArangoQueueTime is used then its value takes precedence in other case value of ctx.Deadline will be taken
func WithAsync ¶ added in v2.0.3
WithAsync is used to configure a context to make an async operation - requires Connection with Async wrapper!
func WithAsyncID ¶ added in v2.0.3
WithAsyncID is used to check an async operation result - requires Connection with Async wrapper!
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
func (*Array) UnmarshalJSON ¶
type AsyncConnectionWrapper ¶ added in v2.0.3
type AsyncConnectionWrapper struct {
Connection
}
type Authentication ¶
func NewBasicAuth ¶
func NewBasicAuth(username, password string) Authentication
func NewHeaderAuth ¶
func NewHeaderAuth(key, value string, args ...interface{}) Authentication
type AuthenticationGetter ¶
type AuthenticationGetter func(ctx context.Context, conn Connection) (Authentication, error)
type Connection ¶
type Connection interface {
// NewRequest initializes Request object
NewRequest(method string, urls ...string) (Request, error)
// NewRequestWithEndpoint initializes Request object with specific endpoint
NewRequestWithEndpoint(endpoint string, method string, urls ...string) (Request, error)
// Do executes the given Request and parses the response into output
// If allowed status codes are provided, they will be checked before decoding the response body.
// In case of mismatch shared.ArangoError will be returned
Do(ctx context.Context, request Request, output interface{}, allowedStatusCodes ...int) (Response, error)
// Stream executes the given Request and returns a reader for Response body
Stream(ctx context.Context, request Request) (Response, io.ReadCloser, error)
// GetEndpoint returns Endpoint which is currently used to execute requests
GetEndpoint() Endpoint
// SetEndpoint changes Endpoint which is used to execute requests
SetEndpoint(e Endpoint) error
// GetAuthentication returns Authentication
GetAuthentication() Authentication
// SetAuthentication returns Authentication parameters used to execute requests
SetAuthentication(a Authentication) error
// Decoder returns Decoder to use for Response body decoding
Decoder(contentType string) Decoder
}
func NewConnectionAsyncWrapper ¶ added in v2.0.3
func NewConnectionAsyncWrapper(conn Connection) Connection
func NewHttp2Connection ¶
func NewHttp2Connection(config Http2Configuration) Connection
func NewHttpConnection ¶
func NewHttpConnection(config HttpConfiguration) Connection
func NewRetryWrapper ¶
func NewRetryWrapper(conn Connection, retries int, wrapper RetryWrapper) Connection
func RetryOn503 ¶
func RetryOn503(conn Connection, retries int) Connection
type ContextKey ¶
type ContextKey string
type Endpoint ¶
type Endpoint interface {
// Get returns provided endpoint if it is known, otherwise chooses one endpoint from existing list
// Endpoint implementation might use the Request method and path values to determine which endpoint to return
Get(endpoint, method, path string) (string, error)
// List returns known endpoints
List() []string
}
func NewEndpoints
deprecated
func NewMaglevHashEndpoints ¶ added in v2.0.3
func NewMaglevHashEndpoints(eps []string, extractor RequestHashValueExtractor) (Endpoint, error)
NewMaglevHashEndpoints returns Endpoint manager which consistently returns the same endpoint based on value extracted from request using provided RequestHashValueExtractor e.g. if you want to use DB name from URL for hashing you can use RequestDBNameValueExtractor
func NewRoundRobinEndpoints ¶ added in v2.0.3
NewRoundRobinEndpoints returns Endpoint manager which runs round-robin
type ErrorAsyncJobInProgress ¶ added in v2.0.3
type ErrorAsyncJobInProgress struct {
// contains filtered or unexported fields
}
func (ErrorAsyncJobInProgress) Error ¶ added in v2.0.3
func (a ErrorAsyncJobInProgress) Error() string
type Factory ¶
type Factory func() (Connection, error)
type Http2Configuration ¶
type Http2Configuration struct {
Authentication Authentication
Endpoint Endpoint
ContentType string
Transport *http2.Transport
}
func (Http2Configuration) GetContentType ¶
func (h Http2Configuration) GetContentType() string
type HttpConfiguration ¶
type HttpConfiguration struct {
Authentication Authentication
Endpoint Endpoint
ContentType string
Transport http.RoundTripper
}
func (HttpConfiguration) GetContentType ¶
func (h HttpConfiguration) GetContentType() string
type RequestHashValueExtractor ¶ added in v2.0.3
RequestHashValueExtractor accepts request method and full request path and must return a value which will be used for hash calculation
type RequestModifier ¶
func WithBody ¶
func WithBody(i interface{}) RequestModifier
func WithFragment ¶
func WithFragment(s string) RequestModifier
func WithQuery ¶
func WithQuery(s, value string) RequestModifier
func WithTransactionID ¶
func WithTransactionID(transactionID string) RequestModifier
type Response ¶
type Response interface {
// Code returns an HTTP compatible status code of the response.
Code() int
// Response returns underlying response object
Response() interface{}
// Endpoint returns the endpoint that handled the request.
Endpoint() string
// Content returns Content-Type
Content() string
// Header gets the first value associated with the given key.
// If there are no values associated with the key, Get returns "".
Header(name string) string
}
func Call ¶
func Call(ctx context.Context, c Connection, method, url string, output interface{}, modifiers ...RequestModifier) (Response, error)
func CallDelete ¶
func CallDelete(ctx context.Context, c Connection, url string, output interface{}, modifiers ...RequestModifier) (Response, error)
func CallGet ¶
func CallGet(ctx context.Context, c Connection, url string, output interface{}, modifiers ...RequestModifier) (Response, error)
func CallHead ¶
func CallHead(ctx context.Context, c Connection, url string, output interface{}, modifiers ...RequestModifier) (Response, error)
func CallPatch ¶
func CallPatch(ctx context.Context, c Connection, url string, output interface{}, body interface{}, modifiers ...RequestModifier) (Response, error)
func CallPost ¶
func CallPost(ctx context.Context, c Connection, url string, output interface{}, body interface{}, modifiers ...RequestModifier) (Response, error)
func CallPut ¶
func CallPut(ctx context.Context, c Connection, url string, output interface{}, body interface{}, modifiers ...RequestModifier) (Response, error)
func CallStream ¶
func CallStream(ctx context.Context, c Connection, method, url string, modifiers ...RequestModifier) (Response, io.ReadCloser, error)
CallStream performs HTTP request with the given method and URL. It returns the response and body reader to read the data from there. The caller is responsible to free the response body.
func CallWithChecks ¶ added in v2.0.3
func CallWithChecks(ctx context.Context, c Connection, method, url string, output interface{}, allowedStatusCodes []int, modifiers ...RequestModifier) (Response, error)
type RetryWrapper ¶
type Wrapper ¶
type Wrapper func(c Connection) Connection
func NewJWTAuthWrapper ¶
func WrapAuthentication ¶
func WrapAuthentication(getter AuthenticationGetter) Wrapper
Source Files
¶
- auth.go
- auth_basic_impl.go
- auth_header_impl.go
- auth_jwt_impl.go
- call.go
- connection.go
- connection_http.go
- connection_http2.go
- connection_http_bytes.go
- connection_http_internal.go
- connection_http_json.go
- connection_http_request.go
- connection_http_response.go
- connection_http_vpack.go
- connection_pool.go
- context.go
- data_array.go
- data_stream.go
- decoder.go
- endpoint.go
- endpoints_maglev_hash.go
- endpoints_round_robin.go
- error.go
- modifiers.go
- wrapper_async.go
- wrapper_reauthentication.go
- wrapper_retry.go