mirror of
https://github.com/jeremyd/ergo.git
synced 2026-08-13 00:53:05 -07:00
add a sqlite history backend (#2352)
This commit is contained in:
committed by
GitHub
parent
1b673f049f
commit
768c01c17b
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2020 Shivaram Lingamneni
|
||||
// released under the MIT license
|
||||
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// maximum length in bytes of any message target (nickname or channel name) in its
|
||||
// canonicalized (i.e., casefolded) state:
|
||||
MaxTargetLength = 64
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
// these are intended to be written directly into the config file:
|
||||
Enabled bool
|
||||
DatabasePath string `yaml:"database-path"`
|
||||
BusyTimeout time.Duration `yaml:"busy-timeout"`
|
||||
MaxConns int `yaml:"max-conns"`
|
||||
|
||||
// XXX these are copied from elsewhere in the config:
|
||||
ExpireTime time.Duration
|
||||
TrackAccountMessages bool
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
//go:build !sqlite
|
||||
|
||||
// Copyright (c) 2020 Shivaram Lingamneni
|
||||
// released under the MIT license
|
||||
|
||||
// Package sqlite provides a stub implementation when SQLite support is not enabled.
|
||||
// To enable SQLite support, build with: make build_full
|
||||
// This stub prevents the binary from including the large modernc.org/sqlite driver dependencies.
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ergochat/ergo/irc/history"
|
||||
"github.com/ergochat/ergo/irc/logger"
|
||||
)
|
||||
|
||||
// Enabled is false when SQLite support is not compiled in
|
||||
const Enabled = false
|
||||
|
||||
// SQLite is a stub implementation when the sqlite build tag is not present
|
||||
type SQLite struct {
|
||||
history.Database
|
||||
}
|
||||
|
||||
// NewSQLiteDatabase returns an error when SQLite support is not compiled in
|
||||
func NewSQLiteDatabase(logger *logger.Manager, config Config) (*SQLite, error) {
|
||||
return nil, errors.New("SQLite support not enabled in this build. Rebuild with `make build_full` to enable")
|
||||
}
|
||||
|
||||
// SetConfig is a no-op for the stub implementation
|
||||
func (s *SQLite) SetConfig(config Config) {
|
||||
// no-op
|
||||
}
|
||||
Reference in New Issue
Block a user