connect

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CouchbaseConnection added in v1.1.0

type CouchbaseConnection struct {

	//The logger.
	Logger *clog.CompositeLogger
	//The connection resolver.
	ConnectionResolver *CouchbaseConnectionResolver
	//The configuration options.
	Options *cconf.ConfigParams
	//The Couchbase cluster connection object.
	Connection *gocb.Cluster
	//The Couchbase bucket name.
	BucketName string
	//The Couchbase bucket object.
	Bucket        *gocb.Bucket
	Authenticator gocb.PasswordAuthenticator
	// contains filtered or unexported fields
}

CouchbaseConnection it is couchbase connection using plain couchbase driver. This is the most basic persistence component that is only able to store data items of any type. Specific CRUD operations over the data items must be implemented in child classes by accessing c.Connection properties.

Configuration parameters:

  • bucket: (optional) Couchbase bucket name

  • connection(s):

  • discovery_key: (optional) a key to retrieve the connection from connect.idiscovery.html IDiscovery]]

  • host: host name or IP address

  • port: port number (default: 27017)

  • uri: resource URI or connection string with all parameters in it

  • credential(s):

  • store_key: (optional) a key to retrieve the credentials from auth.icredentialstore.html ICredentialStore]]

  • username: (optional) user name

  • password: (optional) user password

  • options:

  • auto_create: (optional) automatically create missing bucket (default: false)

  • auto_index: (optional) automatically create primary index (default: false)

  • flush_enabled: (optional) bucket flush enabled (default: false)

  • bucket_type: (optional) bucket type (default: couchbase)

  • ram_quota: (optional) RAM quota in MB (default: 100)

    References:

- *:logger:*:*:1.0 (optional) ILogger components to pass log messages - *:discovery:*:*:1.0 (optional) IDiscovery services - *:credential-store:\*:\*:1.0 (optional) Credential stores to resolve credentials

func NewCouchbaseConnection added in v1.1.0

func NewCouchbaseConnection(bucketName string) *CouchbaseConnection

NewCouchbaseConnection are creates a new instance of the connection component. Parameters:

  • bucketName the name of couchbase bucket

func (*CouchbaseConnection) Close added in v1.1.0

func (c *CouchbaseConnection) Close(correlationId string) (err error)

Closes component and frees used resources. Parameters:

  • correlationId (optional) transaction id to trace execution through call chain.

Returns: error error or null no errors occured.

func (*CouchbaseConnection) Configure added in v1.1.0

func (c *CouchbaseConnection) Configure(config *cconf.ConfigParams)

Configure are configures component by passing configuration parameters. Parameters:

  • config configuration parameters to be set.

func (*CouchbaseConnection) GetBucket added in v1.1.0

func (c *CouchbaseConnection) GetBucket() *gocb.Bucket

GetBucket method are returned opened bucket

func (*CouchbaseConnection) GetBucketName added in v1.1.0

func (c *CouchbaseConnection) GetBucketName() string

GetBucketName method are returned bucket name

func (*CouchbaseConnection) GetConnection added in v1.1.0

func (c *CouchbaseConnection) GetConnection() *gocb.Cluster

GetConnection method are return opened connection

func (*CouchbaseConnection) IsOpen added in v1.1.0

func (c *CouchbaseConnection) IsOpen() bool

IsOpen method are checks if the component is opened. Retrun true if the component has been opened and false otherwise.

func (*CouchbaseConnection) Open added in v1.1.0

func (c *CouchbaseConnection) Open(correlationId string) (err error)

Open method are opens the component. Parameters:

  • correlationId (optional) transaction id to trace execution through call chain.

Returns: error error or nil no errors occured.

func (*CouchbaseConnection) SetReferences added in v1.1.0

func (c *CouchbaseConnection) SetReferences(references cref.IReferences)

SetReferences are sets references to dependent components. Parameters:

  • references references to locate the component dependencies.

type CouchbaseConnectionParams

type CouchbaseConnectionParams struct {
	Uri      string `json: "uri"`
	Username string `json "username"`
	Password string `json: "password"`
}

CouchbaseConnectionParams struct for save connection params

type CouchbaseConnectionResolver

type CouchbaseConnectionResolver struct {
	//The connections resolver.
	ConnectionResolver *ccon.ConnectionResolver
	//The credentials resolver.
	CredentialResolver *cauth.CredentialResolver
}

CouchbaseConnectionResolver helper class that resolves Couchbase connection and credential parameters, validates them and generates a connection URI.

It is able to process multiple connections to Couchbase cluster nodes.

Configuration parameters:

  • connection(s):
  • discovery_key: (optional) a key to retrieve the connection from IDiscovery
  • host: host name or IP address
  • port: port number (default: 27017)
  • database: database (bucket) name
  • uri: resource URI or connection string with all parameters in it
  • credential(s):
  • store_key: (optional) a key to retrieve the credentials from auth.icredentialstore.html ICredentialStore
  • username: user name
  • password: user password

References:

- *:discovery:*:*:1.0 (optional) IDiscovery services - *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

func NewCouchbaseConnectionResolver

func NewCouchbaseConnectionResolver() *CouchbaseConnectionResolver

NewCouchbaseConnectionResolver method creates new instance of CouchbaseConnectionResolver Retruns *CouchbaseConnectionResolver

func (*CouchbaseConnectionResolver) Configure

func (c *CouchbaseConnectionResolver) Configure(config *cconf.ConfigParams)

Configures component by passing configuration parameters. Parameters:

  • config configuration parameters to be set.

func (*CouchbaseConnectionResolver) Resolve

func (c *CouchbaseConnectionResolver) Resolve(correlationId string) (connection *CouchbaseConnectionParams, err error)

Resolves Couchbase connection URI from connection and credential parameters. Parameters:

  • correlationId (optional) transaction id to trace execution through call chain.

Returns: connection *CouchbaseConnectionParams, err error resolved connection params or error.

func (*CouchbaseConnectionResolver) SetReferences

func (c *CouchbaseConnectionResolver) SetReferences(references cref.IReferences)

Sets references to dependent components.

  • references references to locate the component dependencies.

Jump to

Keyboard shortcuts

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