arangoctl

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Kind for resource config not provided
	InvalidKind = errors.New("kind missing or invalid type. Must be string")
)

Functions

This section is empty.

Types

type Client

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

Client is a general client for interactive with Arango cluster

func NewClient

func NewClient(config ClientConfig) (*Client, error)

func (*Client) ApplyIndex

func (c *Client) ApplyIndex(collection string, index CollectionIndex) (driver.Index, bool, error)

func (*Client) CheckOrCreateCollection

func (c *Client) CheckOrCreateCollection(name string, collectionType string) error

CheckOrCreateCollection checks if collection exists and if not will create it. This is mostly used by apply operation It will also error out if the collection exists but not same type as Arango really does not allow to change type of an existing collection

func (*Client) CreateView

func (c *Client) CreateView(name string, options *driver.ArangoSearchViewProperties) (driver.View, error)

func (*Client) GetIndexes

func (c *Client) GetIndexes(collection string) ([]driver.Index, error)

func (*Client) GetView

func (c *Client) GetView(view string) (driver.View, error)

func (*Client) UpdateView

func (c *Client) UpdateView(name string, options driver.ArangoSearchViewProperties) error

func (*Client) ViewExists

func (c *Client) ViewExists(view string) (bool, error)

type ClientConfig

type ClientConfig struct {
	Db             string
	Endpoints      []string
	Authentication ClusterAuthentication
	Context        context.Context
}

type ClusterAuthentication

type ClusterAuthentication struct {
	Type     string `json:"type"`
	Username string `json:"username"`
	Password string `json:"password"`
}

ClusterAuthentication contains auth details to connect to the cluster

type ClusterConfig

type ClusterConfig struct {
	Meta ClusterMeta `json:"meta"`
	Spec ClusterSpec `json:"spec"`
}

ClusterConfig stores information about a cluster that's referred to by one or more topic configs. These configs should reflect the reality of what's been set up externally; there's no way to "apply" these at the moment.

func LoadClusterBytes

func LoadClusterBytes(contents []byte) (ClusterConfig, error)

LoadClusterBytes loads a ClusterConfig from YAML bytes

func LoadClusterFile

func LoadClusterFile(path string) (ClusterConfig, error)

LoadClusterFile loads a ClusterConfig from a apth to YAML file

func (ClusterConfig) NewAdminClient

func (c ClusterConfig) NewAdminClient(ctx context.Context) (*Client, error)

NewAdminClient returns a new admin client using parameters in the current config

type ClusterMeta

type ClusterMeta struct {
	Name        string `json:"name"`
	Environment string `json:"environment"`
	Description string `json:"description"`
}

ClusterMeta contains (mostly immutable) metadata about the cluster. Inspired by the meta fields in Kubernetes objects.

type ClusterSpec

type ClusterSpec struct {
	// Database to use for this connection
	// This database already has to be present
	Db string `json:"db"`

	Authentication ClusterAuthentication `json:"auth"`

	// BootstrapAddrs is a list of one or more broker bootstrap addresses. These can use IPs
	// or DNS names.
	Endpoints []string `json:"endpoints"`
}

ClusterSpec contains the details necessary to communicate with a ArangoDB cluster.

type Collection

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

Collection implementation of resource

func (*Collection) Apply

func (c *Collection) Apply(client *Client) error

Apply applies collection based on config specs

func (*Collection) GetKind

func (c *Collection) GetKind() string

GetKind implements Resource.Getkind interface

type CollectionConfig

type CollectionConfig struct {
	Kind string         `json:"Kind"`
	Meta CollectionMeta `json:"meta"`
	Spec CollectionSpec `json:"spec"`
}

CollectionConfig defines YAML for collection resource

func (CollectionConfig) GetResource

func (c CollectionConfig) GetResource() Resource

type CollectionIndex

type CollectionIndex struct {
	Name    string                 `json:"name"`
	Type    string                 `json:"type"`
	Fields  []string               `json:"fields"`
	Options CollectionIndexOptions `json:"options"`
}

CollectionIndex defines one index

type CollectionIndexOptions

type CollectionIndexOptions struct {
	Unique       bool `json:"unique"`
	Sparse       bool `json:"sparse"`
	InBackground bool `json:"inbackground"`
}

CollectionIndexOptions defines options for an index Different index type have different set of option but this is a global object that is a superset of all options. We will pick and choose the relevant one when we create indexes based on type

type CollectionMeta

type CollectionMeta struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

CollectionMeta defines mostly immutable parts of collections. We dont allow renaming of collection name through collection meta yet

type CollectionSpec

type CollectionSpec struct {
	Indexes []CollectionIndex `json:"indexes"`
}

CollectionSpec defines the mutable part of collections As of now we only let you update indexes

type Resource

type Resource interface {
	Apply(client *Client) error
	GetKind() string
}

Resource provides methods to identify resource and do operation on it

type ResourceConfig

type ResourceConfig interface {
	GetResource() Resource
}

ResourceConfig provides methods to convert to actual arango Resource object

func LoadResourceBytes

func LoadResourceBytes(contents []byte) (ResourceConfig, error)

LoadResourceBytes loads ResourceConfig from YAML bytes

func LoadResourceFile

func LoadResourceFile(path string) (ResourceConfig, error)

LoadResourceFile loads a generic map interface from a

type SearchView

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

View implementation of resource

func (*SearchView) Apply

func (v *SearchView) Apply(client *Client) error

func (*SearchView) GetKind

func (v *SearchView) GetKind() string

type SearchViewConfig

type SearchViewConfig struct {
	Kind string   `json:"Kind"`
	Meta ViewMeta `json:"meta"`
	// I think its just easier to map the prorperties to view
	// as it lets us expand on it later on
	SearchViewProperties driver.ArangoSearchViewProperties `json:"spec"`
}

SearchViewConfig defines YAML for view resource

func (SearchViewConfig) GetResource

func (v SearchViewConfig) GetResource() Resource

type ViewMeta

type ViewMeta struct {
	Name string `json:"name"`
}

ViewMeta defines immutable parts of collections We dont allow renaming of views yet. You will just have to delete and apply it again

Jump to

Keyboard shortcuts

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