Documentation
¶
Index ¶
- Constants
- Variables
- type SurrealDatabase
- type SurrealDriver
- func (sd *SurrealDriver) ClearTables(ctx context.Context, container mconfig.ContainerInformation) error
- func (sd *SurrealDriver) CreateContainer(ctx context.Context, c *client.Client, a mconfig.ContainerAllocation) (string, error)
- func (sd *SurrealDriver) DropTables(ctx context.Context, container mconfig.ContainerInformation) error
- func (sd *SurrealDriver) GetImage() string
- func (sd *SurrealDriver) GetRequiredPorts() []string
- func (sd *SurrealDriver) GetUniqueId() string
- func (sd *SurrealDriver) HandleInstruction(ctx context.Context, c *client.Client, container mconfig.ContainerInformation, ...) error
- func (sd *SurrealDriver) Host(ctx *mconfig.Context) mconfig.EnvironmentValue
- func (sd *SurrealDriver) Initialize(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) error
- func (sd *SurrealDriver) IsHealthy(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) (bool, error)
- func (sd *SurrealDriver) Load(data string) (mconfig.ServiceDriver, error)
- func (sd *SurrealDriver) NewDatabase(namespace string, database string) *SurrealDriver
- func (sd *SurrealDriver) Password() mconfig.EnvironmentValue
- func (sd *SurrealDriver) Port(ctx *mconfig.Context) mconfig.EnvironmentValue
- func (sd *SurrealDriver) Save() (string, error)
- func (sd *SurrealDriver) Username() mconfig.EnvironmentValue
Constants ¶
const ( SurrealUsername = "root" SurrealPassword = "root" )
IMPORTANT: Having non-static passwords would make Magic not works as the Container allocation currently does not contain service driver data.
This means that instruction calling would break if we added back password and username changing.
Variables ¶
var RequiredPorts = []string{
"8000/tcp",
}
Functions ¶
This section is empty.
Types ¶
type SurrealDatabase ¶
type SurrealDatabase struct {
Namespace string `json:"namespace"`
Database string `json:"database"`
}
A single SurrealDB database inside of a namespace. SurrealDB always scopes databases by namespaces, so both are required to connect to one.
type SurrealDriver ¶
type SurrealDriver struct {
Image string `json:"image"`
Databases []SurrealDatabase `json:"databases"`
}
func NewDriver ¶
func NewDriver(image string) *SurrealDriver
Create a new SurrealDB service driver.
It currently only supports SurrealDB v3.
func (*SurrealDriver) ClearTables ¶
func (sd *SurrealDriver) ClearTables(ctx context.Context, container mconfig.ContainerInformation) error
Clear all tables in all namespaces/databases (keeps the table definitions intact, just removes all of the records)
func (*SurrealDriver) CreateContainer ¶
func (sd *SurrealDriver) CreateContainer(ctx context.Context, c *client.Client, a mconfig.ContainerAllocation) (string, error)
Should create a new container for the database or use the existing one (returns container id + error in case one happened)
func (*SurrealDriver) DropTables ¶
func (sd *SurrealDriver) DropTables(ctx context.Context, container mconfig.ContainerInformation) error
Drop all tables in all namespaces/databases (actually deletes all of your tables)
func (*SurrealDriver) GetImage ¶
func (sd *SurrealDriver) GetImage() string
func (*SurrealDriver) GetRequiredPorts ¶
func (sd *SurrealDriver) GetRequiredPorts() []string
func (*SurrealDriver) GetUniqueId ¶
func (sd *SurrealDriver) GetUniqueId() string
A unique identifier for the database driver. This is appended to the container name to make sure we know it's the container from the driver.
func (*SurrealDriver) HandleInstruction ¶
func (sd *SurrealDriver) HandleInstruction(ctx context.Context, c *client.Client, container mconfig.ContainerInformation, instruction mconfig.Instruction) error
Handles the instructions for SurrealDB. Supports the following instructions currently: - Clear tables - Drop tables
func (*SurrealDriver) Host ¶
func (sd *SurrealDriver) Host(ctx *mconfig.Context) mconfig.EnvironmentValue
Get hostname of the database container created by the driver as a EnvironmentValue for your config.
func (*SurrealDriver) Initialize ¶
func (sd *SurrealDriver) Initialize(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) error
Initialize the container by creating all of the namespaces and databases the driver should manage
func (*SurrealDriver) IsHealthy ¶
func (sd *SurrealDriver) IsHealthy(ctx context.Context, c *client.Client, container mconfig.ContainerInformation) (bool, error)
Check for SurrealDB health using the built-in is-ready command
func (*SurrealDriver) Load ¶
func (sd *SurrealDriver) Load(data string) (mconfig.ServiceDriver, error)
func (*SurrealDriver) NewDatabase ¶
func (sd *SurrealDriver) NewDatabase(namespace string, database string) *SurrealDriver
NewDatabase registers a new database for the driver. Since SurrealDB always scopes databases by namespaces, both the namespace and the database name have to be specified.
func (*SurrealDriver) Password ¶
func (sd *SurrealDriver) Password() mconfig.EnvironmentValue
Get the password for the user of the databases in this driver as a EnvironmentValue for your config.
func (*SurrealDriver) Port ¶
func (sd *SurrealDriver) Port(ctx *mconfig.Context) mconfig.EnvironmentValue
Get the port of the database container created by the driver as a EnvironmentValue for your config.
func (*SurrealDriver) Save ¶
func (sd *SurrealDriver) Save() (string, error)
func (*SurrealDriver) Username ¶
func (sd *SurrealDriver) Username() mconfig.EnvironmentValue
Get the username of the databases in this driver as a EnvironmentValue for your config.