connection

package
v2.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 20 Imported by: 14

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

View Source
const (
	PlainText              = "text/plain"
	ApplicationOctetStream = "application/octet-stream"
	ApplicationZip         = "application/zip"
)
View Source
const (
	ApplicationJSON = "application/json"
)
View Source
const (
	ApplicationVPack = "application/x-velocypack"
)
View Source
const (
	ContentType = "content-type"
)

Variables

View Source
var ErrReaderOutputBytes = errors.New("use *[]byte as output argument")

ErrReaderOutputBytes is the error to inform caller about invalid output argument.

View Source
var ErrWriterInputBytes = errors.New("use []byte as input argument")

ErrWriterInputBytes is the error to inform caller about invalid input argument.

Functions

func FixupEndpointURLScheme

func FixupEndpointURLScheme(u string) string

FixupEndpointURLScheme changes endpoint URL schemes used by arangod to ones used by go. E.g. "tcp://localhost:8529" -> "http://localhost:8529"

func IsCodeError

func IsCodeError(err error, code int) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func NewError

func NewError(code int, message string) error

func NewErrorf

func NewErrorf(code int, message string, args ...interface{}) error

func NewHTTP2DialForEndpoint

func NewHTTP2DialForEndpoint(e Endpoint) func(network, addr string, cfg *tls.Config) (net.Conn, error)

func NewNotFoundError

func NewNotFoundError(msg string) error

func NewUrl

func NewUrl(parts ...string) string

NewUrl returns the path in the URL.

func WithArangoQueueTime

func WithArangoQueueTime(parent context.Context, duration time.Duration) context.Context

WithArangoQueueTime defines max queue timeout on the server side.

func WithArangoQueueTimeout

func WithArangoQueueTimeout(parent context.Context, useQueueTimeout bool) context.Context

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 WithDriverFlags

func WithDriverFlags(parent context.Context, value []string) context.Context

WithDriverFlags is used to configure additional flags for the `x-arango-driver` header.

Types

type Array

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

func (*Array) More

func (a *Array) More() bool

func (*Array) Unmarshal

func (a *Array) Unmarshal(i interface{}) error

func (*Array) UnmarshalJSON

func (a *Array) UnmarshalJSON(d []byte) error

type Authentication

type Authentication interface {
	RequestModifier(r Request) error
}

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
	Do(ctx context.Context, request Request, output interface{}) (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 NewHttp2Connection

func NewHttp2Connection(config Http2Configuration) Connection

func NewHttpConnection

func NewHttpConnection(config HttpConfiguration) Connection

func NewPool

func NewPool(connections int, factory Factory) (Connection, error)

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 Decoder

type Decoder interface {
	Decode(reader io.Reader, obj interface{}) error
	Encode(writer io.Writer, obj interface{}) error
	Reencode(in, out interface{}) error
}

type Endpoint

type Endpoint interface {
	// Get return one of endpoints if is valid, if no default one is returned
	Get(endpoints ...string) (string, bool)

	List() []string
}

func NewEndpoints

func NewEndpoints(e ...string) Endpoint

type Error

type Error struct {
	Code    int
	Message string
}

func (Error) Error

func (e Error) 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 Request

type Request interface {
	Method() string
	URL() string

	Endpoint() string

	SetBody(i interface{}) error
	AddHeader(key, value string)
	AddQuery(key, value string)

	GetHeader(key string) (string, bool)
	GetQuery(key string) (string, bool)

	SetFragment(s string)
}

type RequestModifier

type RequestModifier func(r Request) error

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
}

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.

type RetryWrapper

type RetryWrapper func(response Response, err error) bool

type Wrapper

type Wrapper func(c Connection) Connection

func NewJWTAuthWrapper

func NewJWTAuthWrapper(username, password string) Wrapper

func WrapAuthentication

func WrapAuthentication(getter AuthenticationGetter) Wrapper

Jump to

Keyboard shortcuts

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