Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithConfigFile ¶
func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption
WithConfigFile sets the config file to be used for the valkey container, and sets the command to run the valkey server using the passed config file
func WithLogLevel ¶
func WithLogLevel(level LogLevel) testcontainers.CustomizeRequestOption
WithLogLevel sets the log level for the valkey server process See https://redis.io/docs/reference/modules/modules-api-ref/#redismodule_log for more information.
func WithSnapshotting ¶
func WithSnapshotting(seconds int, changedKeys int) testcontainers.CustomizeRequestOption
WithSnapshotting sets the snapshotting configuration for the valkey server process. You can configure Valkey to have it save the dataset every N seconds if there are at least M changes in the dataset. This method allows Valkey to benefit from copy-on-write semantics. See https://redis.io/docs/management/persistence/#snapshotting for more information.
Types ¶
type LogLevel ¶
type LogLevel string
const ( // LogLevelDebug is the debug log level LogLevelDebug LogLevel = "debug" // LogLevelVerbose is the verbose log level LogLevelVerbose LogLevel = "verbose" // LogLevelNotice is the notice log level LogLevelNotice LogLevel = "notice" // LogLevelWarning is the warning log level LogLevelWarning LogLevel = "warning" )
type ValkeyContainer ¶
type ValkeyContainer struct {
testcontainers.Container
}
ValkeyContainer represents the Valkey container type used in the module
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*ValkeyContainer, error)
Run creates an instance of the Valkey container type
Example ¶
package main
import (
"context"
"fmt"
"log"
"path/filepath"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/valkey"
)
func main() {
// runValkeyContainer {
ctx := context.Background()
valkeyContainer, err := valkey.Run(ctx,
"valkey/valkey:7.2.5",
valkey.WithSnapshotting(10, 1),
valkey.WithLogLevel(valkey.LogLevelVerbose),
valkey.WithConfigFile(filepath.Join("testdata", "valkey7.conf")),
)
defer func() {
if err := testcontainers.TerminateContainer(valkeyContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := valkeyContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
}
Output: true
func RunContainer
deprecated
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*ValkeyContainer, error)
Deprecated: use Run instead RunContainer creates an instance of the Valkey container type
func (*ValkeyContainer) ConnectionString ¶
func (c *ValkeyContainer) ConnectionString(ctx context.Context) (string, error)
ConnectionString returns the connection string for the Valkey container