Documentation
¶
Index ¶
- func CleanupDB(t *testing.T, client *ClickHouse)
- func Disconnect(client *ClickHouse)
- func DropDB(t *testing.T, client *ClickHouse)
- func Migrate(config *ClickHouseConfig) error
- type ClickHouse
- func (ch *ClickHouse) SaveEvents(ctx context.Context, events []model.Event) error
- func (ch *ClickHouse) SavePageViews(ctx context.Context, pageViews []model.PageView) error
- func (ch *ClickHouse) SaveRequests(ctx context.Context, requests []model.Request) error
- func (ch *ClickHouse) SaveSessions(ctx context.Context, sessions []model.Session) error
- func (ch *ClickHouse) Session(ctx context.Context, siteID, fingerprint uint64, maxAge time.Time) (*model.Session, error)
- type ClickHouseConfig
- type Mock
- func (client *Mock) Events() []model.Event
- func (client *Mock) PageViews() []model.PageView
- func (client *Mock) Requests() []model.Request
- func (client *Mock) SaveEvents(_ context.Context, events []model.Event) error
- func (client *Mock) SavePageViews(_ context.Context, pageViews []model.PageView) error
- func (client *Mock) SaveRequests(_ context.Context, requests []model.Request) error
- func (client *Mock) SaveSessions(_ context.Context, sessions []model.Session) error
- func (client *Mock) Session(context.Context, uint64, uint64, time.Time) (*model.Session, error)
- func (client *Mock) Sessions() []model.Session
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupDB ¶
func CleanupDB(t *testing.T, client *ClickHouse)
CleanupDB clears all test database tables.
func Disconnect ¶
func Disconnect(client *ClickHouse)
Disconnect disconnects from the test database.
func Migrate ¶
func Migrate(config *ClickHouseConfig) error
Migrate runs the database migration for a given connection string. This will use the embedded schema migration scripts.
Types ¶
type ClickHouse ¶
type ClickHouse struct {
clickhouse.Conn
// contains filtered or unexported fields
}
ClickHouse implements the Storage interface.
func NewClickHouse ¶
func NewClickHouse(config *ClickHouseConfig) (*ClickHouse, error)
NewClickHouse returns a new ClickHouse client for the given configuration.
func (*ClickHouse) SaveEvents ¶
SaveEvents implements the Storage interface.
func (*ClickHouse) SavePageViews ¶
SavePageViews implements the Storage interface.
func (*ClickHouse) SaveRequests ¶
SaveRequests implements the Storage interface.
func (*ClickHouse) SaveSessions ¶
SaveSessions implements the Storage interface.
type ClickHouseConfig ¶
type ClickHouseConfig struct {
// Hostnames is the database hostname.
Hostnames []string
// Port is the database port.
Port int
// Cluster is the optional database cluster to use.
Cluster string
// Database is the database schema.
Database string
// Username is the database user.
Username string
// Password is the database password.
Password string
// Secure enables TLS encryption.
Secure bool
// SSLSkipVerify skips the SSL verification if set to true.
SSLSkipVerify bool
// MaxOpenConnections sets the number of maximum open connections.
// If set to <= 0, the default value of 20 will be used.
MaxOpenConnections int
// MaxConnectionLifetimeSeconds sets the maximum amount of time a connection will be reused.
// If set to <= 0, the default value of 1800 will be used.
MaxConnectionLifetimeSeconds int
// MaxIdleConnections sets the number of maximum idle connections.
// If set to <= 0, the default value of 5 will be used.
MaxIdleConnections int
// Logger is the log.Logger used for logging.
Logger *slog.Logger
// Debug enables the logger for the ClickHouse connection.
Debug bool
// contains filtered or unexported fields
}
ClickHouseConfig is the configuration for the ClickHouse Storage implementation.
type Mock ¶
Mock implements the Storage interface.
func (*Mock) SaveEvents ¶
SaveEvents implements the Storage interface.
func (*Mock) SavePageViews ¶
SavePageViews implements the Storage interface.
func (*Mock) SaveRequests ¶
SaveRequests implements the Storage interface.
func (*Mock) SaveSessions ¶
SaveSessions implements the Storage interface.
type Storage ¶
type Storage interface {
// SavePageViews saves given hits.
SavePageViews(context.Context, []model.PageView) error
// SaveSessions saves given sessions.
SaveSessions(context.Context, []model.Session) error
// SaveEvents saves given events.
SaveEvents(context.Context, []model.Event) error
// SaveRequests saves given requests.
SaveRequests(context.Context, []model.Request) error
// Session returns the last hit for a given client, fingerprint, and maximum age.
Session(context.Context, uint64, uint64, time.Time) (*model.Session, error)
}
Storage is the database storage interface.