solace

package module
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ServiceAMQP = Service{
		Name:       "amqp",
		Port:       5672,
		Protocol:   "amqp",
		SupportSSL: false,
	}
	ServiceMQTT = Service{
		Name:       "mqtt",
		Port:       1883,
		Protocol:   "tcp",
		SupportSSL: false,
	}
	ServiceREST = Service{
		Name:       "rest",
		Port:       9000,
		Protocol:   "http",
		SupportSSL: false,
	}
	ServiceManagement = Service{
		Name:       "management",
		Port:       8080,
		Protocol:   "http",
		SupportSSL: false,
	}
	ServiceSMF = Service{
		Name:       "smf",
		Port:       55555,
		Protocol:   "tcp",
		SupportSSL: true,
	}
	ServiceSMFSSL = Service{
		Name:       "smf",
		Port:       55443,
		Protocol:   "tcps",
		SupportSSL: true,
	}
)

Functions

This section is empty.

Types

type Container

type Container struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

Container represents a Solace container with additional settings

func Run

Run starts a Solace container with the provided image and options

Example
// runSolaceContainer {
ctx := context.Background()
ctr, err := sc.Run(ctx, "solace/solace-pubsub-standard:latest",
	sc.WithCredentials("admin", "admin"),
	sc.WithServices(sc.ServiceAMQP, sc.ServiceManagement),
	testcontainers.WithEnv(map[string]string{
		"username_admin_globalaccesslevel": "admin",
		"username_admin_password":          "admin",
	}),
	sc.WithShmSize(1<<30),
)
defer func() {
	if err := testcontainers.TerminateContainer(ctr); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
fmt.Println(err)
// }
Output:

<nil>
Example (WithTopicAndQueue)
ctx := context.Background()

ctr, err := sc.Run(ctx, "solace/solace-pubsub-standard:latest",
	sc.WithCredentials("admin", "admin"),
	sc.WithVPN("test-vpn"),
	sc.WithServices(sc.ServiceAMQP, sc.ServiceManagement, sc.ServiceSMF),
	testcontainers.WithEnv(map[string]string{
		"username_admin_globalaccesslevel": "admin",
		"username_admin_password":          "admin",
	}),
	sc.WithShmSize(1<<30),
	sc.WithQueue("TestQueue", "Topic/MyTopic"),
)
defer func() {
	if err := testcontainers.TerminateContainer(ctr); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
fmt.Println(err)
// the [testMessagePublishAndConsume] function is responsible for printing the output
// to the console, so be aware of that when adding it to other examples.
err = testMessagePublishAndConsume(ctr, "TestQueue", "Topic/MyTopic")
fmt.Println(err)
Output:

<nil>
Published message to topic: Topic/MyTopic
Received message: Hello from Solace testcontainers!
Successfully received message from queue: TestQueue
<nil>

func (*Container) BrokerURLFor

func (c *Container) BrokerURLFor(ctx context.Context, service Service) (string, error)

BrokerURLFor returns the origin URL for a given service

func (*Container) Password

func (c *Container) Password() string

Password returns the password configured for the Solace container

func (*Container) Username

func (c *Container) Username() string

Username returns the username configured for the Solace container

func (*Container) VPN

func (c *Container) VPN() string

Vpn returns the VPN name configured for the Solace container

type Option

type Option func(*options) error

Option is an option for the Solace container.

func WithCredentials

func WithCredentials(username, password string) Option

WithCredentials sets the client credentials (username, password)

func WithQueue

func WithQueue(queueName, topic string) Option

WithQueue subscribes a given topic to a queue (for SMF/AMQP testing)

func WithServices

func WithServices(srv ...Service) Option

WithServices configures the services to be exposed with their wait strategies

func WithShmSize

func WithShmSize(size int64) Option

WithShmSize sets the size of the /dev/shm volume

func WithVPN

func WithVPN(vpn string) Option

WithVPN sets the VPN name

func (Option) Customize

Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.

type Service

type Service struct {
	Name       string
	Port       int
	Protocol   string
	SupportSSL bool
}

Service represents a Solace service with its name, port, protocol, and SSL support.

Jump to

Keyboard shortcuts

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