forked from timescale/tsbs
/
creator.go
36 lines (28 loc) · 1.18 KB
/
creator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package targets
// DBCreator is an interface for a benchmark to do the initial setup of a database
// in preparation for running a benchmark against it.
type DBCreator interface {
// Init should set up any connection or other setup for talking to the DB, but should NOT create any databases
Init()
// DBExists checks if a database with the given name currently exists.
DBExists(dbName string) bool
// CreateDB creates a database with the given name.
CreateDB(dbName string) error
// RemoveOldDB removes an existing database with the given name.
RemoveOldDB(dbName string) error
}
// DBCreatorCloser is a DBCreator that also needs a Close method to cleanup any connections
// after the benchmark is finished.
type DBCreatorCloser interface {
DBCreator
// Close cleans up any database connections
Close()
}
// DBCreatorPost is a DBCreator that also needs to do some initialization after the
// database is created (e.g., only one client should actually create the DB, so
// non-creator clients should still set themselves up for writing)
type DBCreatorPost interface {
DBCreator
// PostCreateDB does further initialization after the database is created
PostCreateDB(dbName string) error
}