scylla

package module
v0.0.0-...-e561989 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 12 Imported by: 0

README

NLG ScyllaDB Driver

ScyllaDB driver for the NetLife Guru Go database layer.

Use scylla to connect ScyllaDB databases to the shared github.com/netlifeguru/db repository API with mapper-backed result scanning.

Go Reference Go Report Card Go Version License


Deprecated

This module has been renamed.

Use the new module instead:

go get github.com/netlifeguru/db-scylla
import "github.com/netlifeguru/db-scylla"

This package is not affiliated with or endorsed by ScyllaDB.

For new projects, use github.com/netlifeguru/db-scylla.

About

scylla is the ScyllaDB driver package for the NetLife Guru Go database stack.

It provides real ScyllaDB database connections that implement the shared db.Conn interface from github.com/netlifeguru/db.

Application code normally imports this package to open ScyllaDB connections, while repository code can depend on the shared db package.

How It Fits Together

Layer Package Purpose
Mapper github.com/netlifeguru/mapper Row-to-struct and map scanning
DB github.com/netlifeguru/db Shared query and repository API
Driver github.com/netlifeguru/scylla Real ScyllaDB database connections

Features

  • ScyllaDB Driver: Connects the shared NetLife Guru database layer to ScyllaDB
  • Shared DB Interface: Provides connections compatible with db.Conn
  • Repository Friendly: Lets repository code use common db helpers such as List, Get, Value, and Maps
  • Mapper Integration: Uses github.com/netlifeguru/mapper for struct, map, and scalar result scanning
  • CQL Model Support: Works with Scylla model.cql files through the shared db package
  • Dialect SQL Support: Supports Scylla-specific CQL through db.DialectSQL
  • Batch Support: Provides Scylla batch workflows through the shared database layer
  • Explicit CQL: Designed for applications that prefer direct CQL and typed repository helpers
  • Standard Go Friendly: Built around context-aware operations, interfaces, structs, and explicit error handling

Requirements

This package requires Go 1.24 or newer.

  • Go: 1.24 or newer
  • Shared dependencies: github.com/netlifeguru/db, github.com/netlifeguru/mapper
  • Database: ScyllaDB-compatible server

Installation

Add the ScyllaDB driver to your project using go get:

go get github.com/netlifeguru/scylla

This also installs the shared db and mapper packages required by the driver.

Basic Usage

import (
	"context"

	"github.com/netlifeguru/db"
	"github.com/netlifeguru/scylla"
)

Once a ScyllaDB connection is created, repository code can work with the shared db.Conn interface:

func ListUsers(ctx context.Context, conn db.Conn) ([]User, error) {
	return db.List[User](ctx, conn, db.Raw(`
		SELECT *
		FROM users
	`))
}

The active ScyllaDB connection uses the Scylla query variant.


Documentation

Full package documentation, guides, and examples are available at:

https://netlife.guru/docs/go/scylla

Shared database layer documentation:

https://netlife.guru/docs/go/db

API reference is also available on pkg.go.dev:

https://pkg.go.dev/github.com/netlifeguru/scylla


Notes

  • This package is the ScyllaDB driver for the shared NetLife Guru database layer.
  • Repository code can depend on github.com/netlifeguru/db while application setup imports this driver.
  • Review package-specific concurrency behavior before using it in highly parallel workloads.
  • Check performance characteristics when using this package in latency-sensitive paths.
  • See the package documentation and examples for limitations and recommended usage patterns.

Versioning

This project follows Semantic Versioning.

See CHANGELOG.md for release history and breaking changes.


Contributing

Community contributions, feedback, and improvements are welcome.

Please read CONTRIBUTING.md before submitting pull requests or opening issues.


Code of Conduct

This project follows a Code of Conduct.

Please read CODE_OF_CONDUCT.md before contributing or participating in discussions.


Author

Created and maintained by NetLife Guru s.r.o.


License

MIT License. See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTxUnsupported = errors.New("scylla: transactions are not supported")

Functions

This section is empty.

Types

type Batch

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

func (*Batch) Add

func (b *Batch) Add(q db.Query) error

func (*Batch) AddSQL

func (b *Batch) AddSQL(query string, args ...any) error

func (*Batch) Execute

func (b *Batch) Execute() error

type BatchConn

type BatchConn interface {
	NewBatch(ctx context.Context, batchType gocql.BatchType) *Batch
	NewLoggedBatch(ctx context.Context) *Batch
	NewUnloggedBatch(ctx context.Context) *Batch
	NewCounterBatch(ctx context.Context) *Batch
}

type Connect

type Connect struct {
	Host       string
	Identifier string
	Timeout    time.Duration
	// contains filtered or unexported fields
}

func New

func New() *Connect

func (*Connect) AnalyzeSQL

func (c *Connect) AnalyzeSQL(q string) (prepared string, placeholders int, err error)

func (*Connect) Close

func (c *Connect) Close() error

func (*Connect) Connection

func (c *Connect) Connection() *gocql.Session

func (*Connect) CreatePool

func (c *Connect) CreatePool(cfg db.Config) error

func (*Connect) DriverName

func (c *Connect) DriverName() string

func (*Connect) Exec

func (c *Connect) Exec(q db.Query) (db.Result, error)

func (*Connect) ExecCtx

func (c *Connect) ExecCtx(ctx context.Context, q db.Query) (db.Result, error)

func (*Connect) Fork

func (c *Connect) Fork() db.Conn

func (*Connect) LoadFile

func (c *Connect) LoadFile() string

func (*Connect) NewBatch

func (c *Connect) NewBatch(ctx context.Context, batchType gocql.BatchType) *Batch

func (*Connect) NewCounterBatch

func (c *Connect) NewCounterBatch(ctx context.Context) *Batch

func (*Connect) NewLoggedBatch

func (c *Connect) NewLoggedBatch(ctx context.Context) *Batch

func (*Connect) NewUnloggedBatch

func (c *Connect) NewUnloggedBatch(ctx context.Context) *Batch

func (*Connect) Query

func (c *Connect) Query(query db.Query, each func(row map[string]any) error) error

func (*Connect) QueryCtx

func (c *Connect) QueryCtx(ctx context.Context, query db.Query, each func(row map[string]any) error) error

func (*Connect) QueryRows

func (c *Connect) QueryRows(ctx context.Context, q db.Query) (mapper.Rows, error)

func (*Connect) SelectSQL

func (c *Connect) SelectSQL(q db.DialectSQL) string

func (*Connect) Settings

func (c *Connect) Settings(identifier string) error

func (*Connect) Transaction

func (c *Connect) Transaction(fn func(tx db.Conn) error) (retErr error)

func (*Connect) TransactionCtx

func (c *Connect) TransactionCtx(ctx context.Context, fn func(tx db.Conn) error) error

type Pool

type Pool struct {
	Connection  *gocql.Session
	Connect     db.Config
	ConfigKey   string
	PoolKey     string
	Refs        int
	Consistency gocql.Consistency
}

type Result

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

func (Result) LastInsertId

func (r Result) LastInsertId() int64

func (Result) RowsAffected

func (r Result) RowsAffected() int64

Jump to

Keyboard shortcuts

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