daemon

package
v0.0.0-...-7c007b9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package daemon contains startup function of SquirrelDB

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "unset"
	Commit  string
	Date    string
)

Functions

func Config

func Config() (config.Config, error, error)

Config return the configuration after validation.

func RunWithSignalHandler

func RunWithSignalHandler(f func(context.Context) error) error

RunWithSignalHandler runs given function with a context that is canceled on kill or ctrl+c If a second ctrl+c is received, return even if f didn't completed.

func SetTestEnvironment

func SetTestEnvironment()

SetTestEnvironment configure few environment variable used in testing. This method MUST be called before first usage of Config(). It will set Cassandra & Redis to use alternative keyspace to avoid confict with normal SquirrelDB. It will only do it if not explicitly set.

Types

type LockFactory

type LockFactory interface {
	CreateLock(name string, timeToLive time.Duration) types.TryLocker
}

type MetricReadWriter

type MetricReadWriter interface {
	types.MetricReader
	types.MetricWriter
}

type SquirrelDB

type SquirrelDB struct {
	ID              uuid.UUID
	Config          config.Config
	ExistingCluster types.Cluster
	MetricRegistry  prometheus.Registerer
	Logger          zerolog.Logger
	// contains filtered or unexported fields
}

SquirrelDB is the SquirrelDB process itself. The Prometheus remote-store.

func (*SquirrelDB) CassandraConnection

func (s *SquirrelDB) CassandraConnection(ctx context.Context) (*connection.Connection, error)

CassandraConnection return the Cassandra connection used for SquirrelDB.

func (*SquirrelDB) CassandraSessionNoKeyspace

func (s *SquirrelDB) CassandraSessionNoKeyspace() (*gocql.Session, error)

CassandraSessionNoKeyspace return a Cassandra without keyspace selected.

func (*SquirrelDB) Cluster

func (s *SquirrelDB) Cluster(ctx context.Context) (types.Cluster, error)

Cluster return an types.Cluster. The returned cluster should be closed after use.

func (*SquirrelDB) DropCassandraData

func (s *SquirrelDB) DropCassandraData(ctx context.Context, forceNonTestKeyspace bool) error

DropCassandraData delete the Cassandra keyspace. If forceNonTestKeyspace also drop if the keyspace is not "squirreldb_test". This method is intended for testing, where keyspace is overrided to squirreldb_test.

func (*SquirrelDB) DropTemporaryStore

func (s *SquirrelDB) DropTemporaryStore(ctx context.Context, forceNonTestKeyspace bool) error

DropTemporaryStore delete the temporary store data. If forceNonTestKeyspace also drop if the namespace prefix is not "test:". This method is intended for testing, where namespace prefix is overrided to "test:". Currently it drop Redis keys that start with namespace prefix.

func (*SquirrelDB) Index

func (s *SquirrelDB) Index(ctx context.Context, manualRunOnce bool, fakeTime func() time.Time) (types.Index, error)

Index return an Index. If manualRunOnce is true, the index should only be used by tests and the test should call InternalRunOnce itself. If fakeTime is not nil, the index should only be used by tests and this allow to simulate longer time range.

func (*SquirrelDB) Init

func (s *SquirrelDB) Init() error

Init initialize SquirrelDB Locks & State. Init could be retried.

func (*SquirrelDB) ListenPort

func (s *SquirrelDB) ListenPort() int

ListenPort return the port listening on. Should not be used before Start(). This is useful for tests that use port "0" to known the actual listenning port.

func (*SquirrelDB) LockFactory

func (s *SquirrelDB) LockFactory(ctx context.Context) (LockFactory, error)

LockFactory return the Lock factory of SquirrelDB.

func (*SquirrelDB) MutableLabelProcessor

func (s *SquirrelDB) MutableLabelProcessor(ctx context.Context) (*mutable.LabelProcessor, error)

func (*SquirrelDB) MutableLabelProvider

func (s *SquirrelDB) MutableLabelProvider(ctx context.Context) (mutable.LabelProvider, error)

func (*SquirrelDB) Run

func (s *SquirrelDB) Run(ctx context.Context) error

func (*SquirrelDB) SchemaLock

func (s *SquirrelDB) SchemaLock(ctx context.Context) (types.TryLocker, error)

SchemaLock return a lock to modify the Cassandra schema.

func (*SquirrelDB) Start

func (s *SquirrelDB) Start(ctx context.Context) error

Start will run SquirrelDB and Init()ializing it. It return when SquirrelDB is ready. On error, we can retry calling Start() which will resume starting SquirrelDB.

func (*SquirrelDB) States

func (s *SquirrelDB) States(ctx context.Context) (types.State, error)

func (*SquirrelDB) Stop

func (s *SquirrelDB) Stop()

func (*SquirrelDB) TSDB

TSDB return the metric persistent store. If started is true the tsdb is started.

func (*SquirrelDB) Telemetry

func (s *SquirrelDB) Telemetry(ctx context.Context) error

Jump to

Keyboard shortcuts

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