cassandra

package
v1.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 10

README

Cassandra Client Provider

The Cassandra Client Provider a simple encapsulation of Cassandra Client. Provided concise APIs, and easy to do batch write.

Configuration
cassandra:
    host: "localhost:9042"
    # security: ${CASSANDRA_SECURITY_ENABLE:false}
    # username: ${CASSANDRA_SECURITY_USERNAME:}
    # password: ${CASSANDRA_SECURITY_PASSWORD:}
    # timeout: "${CASSANDRA_TIMEOUT:3s}"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	CreateKeyspaces(ksc ...*KeyspaceConfig) error
	NewSession(cfg *SessionConfig) (*Session, error)
	NewBatchWriter(session *Session, c *WriterConfig, builderCreator func() StatementBuilder) writer.Writer
}

Interface .

type KeyspaceConfig

type KeyspaceConfig struct {
	Name        string                    `file:"name" env:"CASSANDRA_KEYSPACE"`
	Auto        bool                      `file:"auto"`
	Replication KeyspaceReplicationConfig `file:"replication"`
}

KeyspaceConfig .

type KeyspaceReplicationConfig

type KeyspaceReplicationConfig struct {
	Class  string `file:"class" default:"SimpleStrategy"`
	Factor int32  `file:"factor" default:"2"`
}

KeyspaceReplicationConfig .

type ReconnectionConfig

type ReconnectionConfig struct {
	Enable        bool          `file:"enable" default:"true"`
	CheckInterval time.Duration `file:"check_interval" default:"10m"`
	CheckTimeout  time.Duration `file:"check_timeout" default:"60s"`
}

ReconnectionConfig .

type Session

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

Session manager of gocql.Session.

func (*Session) Close

func (s *Session) Close()

Close .

func (*Session) Session

func (s *Session) Session() *gocql.Session

Session get gocql.Session.

type SessionConfig

type SessionConfig struct {
	Keyspace     KeyspaceConfig     `file:"keyspace"`
	Consistency  string             `file:"consistency" default:"LOCAL_ONE"`
	Reconnection ReconnectionConfig `file:"reconnection"`
}

SessionConfig .

type StatementBuilder

type StatementBuilder interface {
	GetStatement(data interface{}) (string, []interface{}, error)
}

StatementBuilder .

type WriterConfig

type WriterConfig struct {
	Parallelism uint64 `file:"parallelism" default:"4" desc:"parallelism"`
	Batch       struct {
		SizeBytes int           `file:"size_bytes" desc:"cassandra batch failed size bytes"`
		Size      uint64        `file:"size" default:"100" desc:"batch size"`
		Timeout   time.Duration `file:"timeout" default:"30s" desc:"timeout to flush buffer for batch write"`
	} `file:"batch"`
	Retry int `file:"retry" desc:"retry if fail to write"`
}

WriterConfig .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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