Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
}
Container represents the Presto container type used in the module
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the Presto container type. It waits for the coordinator to be fully started by:
- Polling /v1/info until starting=false (catalogs loaded).
- Polling /v1/cluster until at least one worker is active and can accept queries.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/presto"
)
func main() {
// runPrestoContainer {
ctx := context.Background()
prestoContainer, err := presto.Run(ctx, "prestodb/presto:0.286")
defer func() {
if err := testcontainers.TerminateContainer(prestoContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
connStr, err := prestoContainer.ConnectionString(ctx)
if err != nil {
log.Printf("failed to get connection string: %s", err)
return
}
fmt.Println(connStr[:7]) // print "http://"
}
Output: http://
func (*Container) ConnectionString ¶
ConnectionString returns the HTTP connection string for the Presto container, e.g. "http://localhost:8080" (IPv6-safe).
Click to show internal directories.
Click to hide internal directories.