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 redis container, and sets the command to run the redis server using the passed config file
func WithLogLevel ¶
func WithLogLevel(level LogLevel) testcontainers.CustomizeRequestOption
WithLogLevel sets the log level for the redis server process See https://redis.io/docs/reference/modules/modules-api-ref/#redismodule_log for more information.
func WithSnapshotting ¶
WithSnapshotting sets the snapshotting configuration for the redis server process. You can configure Redis to have it save the dataset every N seconds if there are at least M changes in the dataset. This method allows Redis 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 RedisContainer ¶
type RedisContainer struct {
testcontainers.Container
}
func RunContainer ¶
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*RedisContainer, error)
RunContainer creates an instance of the Redis container type
Example ¶
// runRedisContainer { ctx := context.Background() redisContainer, err := redis.RunContainer(ctx, testcontainers.WithImage("docker.io/redis:7"), redis.WithSnapshotting(10, 1), redis.WithLogLevel(redis.LogLevelVerbose), redis.WithConfigFile(filepath.Join("testdata", "redis7.conf")), ) if err != nil { log.Fatalf("failed to start container: %s", err) } // Clean up the container defer func() { if err := redisContainer.Terminate(ctx); err != nil { log.Fatalf("failed to terminate container: %s", err) } }() // } state, err := redisContainer.State(ctx) if err != nil { log.Fatalf("failed to get container state: %s", err) // nolint:gocritic } fmt.Println(state.Running)
Output: true
func (*RedisContainer) ConnectionString ¶
func (c *RedisContainer) ConnectionString(ctx context.Context) (string, error)