neoutils

package
v3.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(cr CypherRunner) error

Check will use the supplied CypherRunner to check connectivity to Neo4j

func CheckWritable

func CheckWritable(cr CypherRunner) error

CheckWritable calls the dbms.cluster.role() procedure and verifies the role if it's LEADER or not.

func EnsureConstraints

func EnsureConstraints(im IndexManager, indexes map[string]string, log *logger.UPPLogger) error

EnsureConstraints will, for a map of labels and properties, check whether a constraint exists for a given property on a given label, and if missing will create one. Creating the unique constraint ensures an index automatically.

func EnsureIndexes

func EnsureIndexes(im IndexManager, indexes map[string]string, log *logger.UPPLogger) error

EnsureIndexes will, for a map of labels and properties, check whether an index exists for a given property on a given label, and if missing will create one.

func NewConstraintViolationError

func NewConstraintViolationError(message string, err error) error

NewConstraintViolationError returns, as an error, a new NewConstraintViolationError with the given message and error details. As a convenience, if err is nil, NewSyscallError returns nil.

func ToReader

func ToReader(v interface{}) io.Reader

Types

type AutoConnectTransactional

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

func (*AutoConnectTransactional) CypherBatch

func (a *AutoConnectTransactional) CypherBatch(queries []*CypherQuery) error

func (*AutoConnectTransactional) EnsureConstraints

func (a *AutoConnectTransactional) EnsureConstraints(constraints map[string]string) error

func (*AutoConnectTransactional) EnsureIndexes

func (a *AutoConnectTransactional) EnsureIndexes(indexes map[string]string) error

func (*AutoConnectTransactional) String

func (a *AutoConnectTransactional) String() string

type BatchCypherRunner

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

func (*BatchCypherRunner) CypherBatch

func (bcr *BatchCypherRunner) CypherBatch(queries []*CypherQuery) error

type ConnectionConfig

type ConnectionConfig struct {
	// BatchSize controls how and whether to batch multiple requests to
	// CypherQuery into a single batch. BatchSize 0 disables this behaviour.
	// Values >0 indicate the largest preferred batch size.  Actual sizes
	// may be larger because values from a single call will never be split.
	BatchSize int
	// Transactional indicates that the connection should use the
	// transactional endpoints in the neo4j REST API.
	Transactional bool
	// Optionally a custom http.Client can be supplied
	HTTPClient *http.Client
	// BackgroundConnect indicates that NeoConnection should be available when
	// neo4j is not available, and will connect and re-connect as required.
	BackgroundConnect bool
}

func DefaultConnectionConfig

func DefaultConnectionConfig() *ConnectionConfig

type ConstraintViolationError

type ConstraintViolationError struct {
	Msg string
	Err error
}

ConstraintViolationError is a possible error the Service can return

func (*ConstraintViolationError) Error

func (err *ConstraintViolationError) Error() string

type CypherQuery

type CypherQuery struct {
	// used by Neo4j HTTP API
	Statement  string                 `json:"statement"`
	Parameters map[string]interface{} `json:"parameters"`

	// Used by neoism, for compatibility purposes
	Result interface{} `json:"-"`
}

Cypher

type CypherRunner

type CypherRunner interface {
	CypherBatch(queries []*CypherQuery) error
}

func NewBatchCypherRunner

func NewBatchCypherRunner(cypherRunner CypherRunner, count int) CypherRunner

type Database

type Database interface {
	// CreateIndex starts a background job in the database that will create and
	// populate the new index of a specified property on nodes of a given label.
	CreateIndex(label, propertyName string) error

	// Indexes lists indexes for a label.  If a blank string is given as the label,
	// returns all indexes.
	Indexes(label string) ([]Index, error)

	// UniqueConstraints get a specific unique constraint for a label and a property.
	// If a blank string is given as the property, return all unique constraints for
	// the label.
	UniqueConstraints(label, propertyName string) ([]UniqueConstraint, error)

	// CreateUniqueConstraint create a unique constraint on a property on nodes
	// with a specific label.
	CreateUniqueConstraint(label, propertyName string) error

	CypherBatch(queries []*CypherQuery) error

	String() string
}

Database

func NewDatabase

func NewDatabase(url string, config *ConnectionConfig) (Database, error)

TODO: Use the discovery endpoint for validation

func UnderlyingDB

func UnderlyingDB(con NeoConnection) Database

type DefaultNeoConnection

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

func (*DefaultNeoConnection) CypherBatch

func (c *DefaultNeoConnection) CypherBatch(cypher []*CypherQuery) error

func (*DefaultNeoConnection) EnsureConstraints

func (c *DefaultNeoConnection) EnsureConstraints(constraints map[string]string) error

func (*DefaultNeoConnection) EnsureIndexes

func (c *DefaultNeoConnection) EnsureIndexes(indexes map[string]string) error

func (*DefaultNeoConnection) String

func (c *DefaultNeoConnection) String() string

type Index

type Index struct {
	Name       string
	Label      string
	Properties []string
}

Indexes

type IndexEnsurer

type IndexEnsurer interface {
	EnsureConstraints(indexes map[string]string) error
	EnsureIndexes(indexes map[string]string) error
}

type IndexManager

type IndexManager interface {
	CreateIndex(label string, propertyName string) error
	Indexes(label string) ([]Index, error)
	CreateUniqueConstraint(label string, propertyName string) error
	UniqueConstraints(label string, propertyName string) ([]UniqueConstraint, error)
}

IndexManager manages the maintenance of indexes and unique constraints

type NeoConnection

type NeoConnection interface {
	CypherRunner
	IndexEnsurer
}

func Connect

func Connect(neoURL string, conf *ConnectionConfig, log *logger.UPPLogger) (NeoConnection, error)

This is the entrypoint for the services trying to connect to Neo4j, where neoURL - the path to Neo4j, conf - the configuration required for logging to Neo4j, log - an optional parameter for logging messages. If not provided, we initialize an object of the type go-logger v2

type NeoError

type NeoError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type NeoErrors

type NeoErrors []NeoError

TODO: Should I use pointers instead

func (NeoErrors) Error

func (nerrs NeoErrors) Error() string

type NeoObject

type NeoObject map[string]interface{}

type NeoResponse

type NeoResponse struct {
	Results []NeoResult `json:"results"`
	Errors  NeoErrors   `json:"errors"`
}

type NeoResult

type NeoResult struct {
	Columns []string `json:"columns"`
	Data    []Record `json:"data"`
}

type Payload

type Payload struct {
	Statements []*CypherQuery `json:"statements"`
}

type QueryResult

type QueryResult []NeoObject

type Record

type Record struct {
	Row []interface{} `json:"row"`
}

type Session

type Session struct {
	Client *http.Client
	Log    bool // Log request and response

	// Optional
	Userinfo *url.Userinfo

	// Optional defaults - can be overridden in a Request
	Header *http.Header
	Params *url.Values

	CommitTxEndpoint string
}

Name borrowed from neoism

func (*Session) Send

func (s *Session) Send(queries ...*CypherQuery) error

type StringerDb

type StringerDb struct{ Database }

StringerDb wraps neoism Database to provide a String function, which outputs the database URL

type TransactionalCypherRunner

type TransactionalCypherRunner struct{ DB Database }

func (TransactionalCypherRunner) CypherBatch

func (cr TransactionalCypherRunner) CypherBatch(queries []*CypherQuery) error

func (TransactionalCypherRunner) String

func (cr TransactionalCypherRunner) String() string

type UniqueConstraint

type UniqueConstraint struct {
	Name       string
	Label      string
	Type       string
	Properties []string
}

Constraints

Jump to

Keyboard shortcuts

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