Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: Dapr module #456

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: support for changing the network name
mdelapenya committed Sep 25, 2023
commit 07d541a76e7a162c967229f53176082be012d45e
9 changes: 9 additions & 0 deletions docs/modules/dapr.md
Original file line number Diff line number Diff line change
@@ -31,6 +31,11 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
- `context.Context`, the Go context.
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.

This entrypoint function will create:

- a Dapr network in which the Dapr container and all its components will be attached. Default name is `dapr-network`.
- a Dapr container.

### Container Options

When starting the Dapr container, you can pass options in a variadic way to configure it.
@@ -46,6 +51,10 @@ for Dapr. E.g. `testcontainers.WithImage("daprio/daprd:1.11.3")`.

It's possible to define the application name used by Dapr with the `WithAppName(name string)` functional option. If not passed, the default value is `dapr-app`.

#### Network Name

It's possible to define the network name used by Dapr with the `WithNetworkName(name string)` functional option. If not passed, the default value is `dapr-network`.

#### Components

You can add components to the Dapr container with the `WithComponents(components ...Component)` functional option. If not passed, the default value is an empty map.
1 change: 1 addition & 0 deletions modules/dapr/examples_test.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ func ExampleRunContainer() {
daprContainer, err := dapr.RunContainer(ctx,
testcontainers.WithImage("daprio/daprd:1.11.3"),
dapr.WithAppName("dapr-app"),
dapr.WithNetworkName("dapr-network"),
dapr.WithComponents(
dapr.NewComponent("pubsub", "pubsub.in-memory", map[string]string{"foo": "bar", "bar": "baz"}),
dapr.NewComponent("statestore", "statestore.in-memory", map[string]string{"baz": "qux", "quux": "quuz"}),
7 changes: 7 additions & 0 deletions modules/dapr/options.go
Original file line number Diff line number Diff line change
@@ -42,6 +42,13 @@ func WithAppName(name string) Option {
}
}

// WithNetworkName defines the network name in which the dapr container is attached.
func WithNetworkName(name string) Option {
return func(o *options) {
o.NetworkName = name
}
}

// componentStruct {
type Component struct {
Name string