surrealdb

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

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

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.

Jump to

Keyboard shortcuts

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