gremcos

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 19 Imported by: 9

README

gremcos

GoDoc build Go Report Card Quality Gate Status Coverage Lines of Code Code Smells

Gremcos is a fork of schwartzmx/gremtune with alterations to make it compatible with Gremlin API of Azure Cosmos DB which is a Graph Database (Gremlin API) for Azure.

Gremcos is a fast, efficient, and easy-to-use client for the TinkerPop graph database stack. It is a gremlin language driver which uses WebSockets to interface with gremlin server and has a strong emphasis on concurrency and scalability. Please keep in mind that gremcos is still under heavy development and although effort is being made to fully cover gremcos with reliable tests, bugs may be present in several areas.

Installation

go get github.com/supplyon/gremcos

Examples

Hints

Response Format

This implementation supports Graphson 2.0 (not 3) in order to be compatible to CosmosDB. This means all the responses from the CosmosDB server as well as the responses from the local gremlin-server have to comply with the 2.0 format.

Azure Cosmos Gremlin Implementation Differences

Modifications where made to gremtune in order to be compliant to Azure Cosmos DB. Differences in gremlin support can be found at: Azure Cosmos DB Gremlin compatibility

This implementation is only working/ compatible with TinkerPop 3.4.0.

Cosmos DB specific error handling is done and described at ErrorHandling.md. For example error responses returned by Cosmos due to a usage rate limit violation are handled accordingly.

License

See LICENSE

3rd Party Licenses

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MimeType = []byte("application/vnd.gremlin-v2.0+json")

MimeType used for communication with the gremlin server.

Functions

func Dial

func Dial(conn interfaces.Dialer, errorChannel chan error, options ...clientOption) (*client, error)

Dial returns a client for interaction with the Gremlin Server specified in the host IP. The client is already connected.

func NewPool

func NewPool(createQueryExecutor QueryExecutorFactoryFunc, maxActiveConnections int, idleTimeout time.Duration, logger zerolog.Logger) (*pool, error)

NewPool creates a new pool which is a QueryExecutor

func NewWebsocket

func NewWebsocket(host string, options ...optionWebsocket) (interfaces.Dialer, error)

NewWebsocket returns a WebSocket dialer to use when connecting to Gremlin Server

func PingInterval

func PingInterval(interval time.Duration) clientOption

PingInterval sets the ping interval, which is the interval to send the ping frame to the peer

func SetAuth

func SetAuth(username string, password string) clientOption

SetAuth sets credentials for an authenticated connection

func SetBufferSize

func SetBufferSize(readBufferSize int, writeBufferSize int) optionWebsocket

SetBufferSize sets the read/write buffer size

func SetReadingWait

func SetReadingWait(wait time.Duration) optionWebsocket

SetReadingWait sets the time for waiting that reading occur

func SetTimeout

func SetTimeout(timeout time.Duration) optionWebsocket

SetTimeout sets the dial handshake timeout

func SetWritingWait

func SetWritingWait(wait time.Duration) optionWebsocket

SetWritingWait sets the time for waiting that writing occur

Types

type Cosmos

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

Cosmos is a connector that can be used to connect to and interact with a CosmosDB

func New

func New(host string, options ...Option) (*Cosmos, error)

New creates a new instance of the Cosmos (-DB connector)

func (*Cosmos) Execute

func (c *Cosmos) Execute(query string) ([]interfaces.Response, error)

func (*Cosmos) ExecuteAsync

func (c *Cosmos) ExecuteAsync(query string, responseChannel chan interfaces.AsyncResponse) (err error)

func (*Cosmos) ExecuteQuery

func (c *Cosmos) ExecuteQuery(query interfaces.QueryBuilder) ([]interfaces.Response, error)

func (*Cosmos) IsConnected

func (c *Cosmos) IsConnected() bool

func (*Cosmos) IsHealthy

func (c *Cosmos) IsHealthy() error

IsHealthy returns nil if the Cosmos DB connection is alive, otherwise an error is returned

func (*Cosmos) Stop

func (c *Cosmos) Stop() error

func (*Cosmos) String

func (c *Cosmos) String() string

type Metrics

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

Metrics represents the collection of metrics internally set by the service.

func NewMetrics

func NewMetrics(namespace string) *Metrics

NewMetrics returns the metrics collection

type Option

type Option func(*Cosmos)

Option is the struct for defining optional parameters for Cosmos

func ConnectionIdleTimeout

func ConnectionIdleTimeout(timeout time.Duration) Option

ConnectionIdleTimeout specifies the timeout after which idle connections will be removed from the internal connection pool

func MetricsPrefix

func MetricsPrefix(prefix string) Option

MetricsPrefix can be used to customize the metrics prefix as needed for a specific service. Per default 'gremcos' is used as prefix.

func NumMaxActiveConnections

func NumMaxActiveConnections(numMaxActiveConnections int) Option

NumMaxActiveConnections specifies the maximum amount of active connections.

func WithAuth

func WithAuth(username string, password string) Option

WithAuth sets credentials for an authenticated connection

func WithLogger

func WithLogger(logger zerolog.Logger) Option

WithLogger specifies the logger to use

type QueryExecutorFactoryFunc

type QueryExecutorFactoryFunc func() (interfaces.QueryExecutor, error)

Directories

Path Synopsis
examples
test
mocks/interfaces
Package mock_interfaces is a generated GoMock package.
Package mock_interfaces is a generated GoMock package.
mocks/metrics
Package mock_metrics is a generated GoMock package.
Package mock_metrics is a generated GoMock package.

Jump to

Keyboard shortcuts

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