Skip to content

Commit

Permalink
chore: update docs to reflect new resource patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
worstell committed Dec 16, 2024
1 parent 7534973 commit 7e48800
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
13 changes: 10 additions & 3 deletions docs/content/docs/reference/pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ First, declare a new topic:
```go
package payments

var Invoices = ftl.Topic[Invoice]("invoices")
type Invoices = ftl.TopicHandle[Invoice, ftl.SinglePartitionMap[Invoice]]
```

Note that the name of the topic as represented in the FTL schema is the lower camel case version of the type name.

The `Invoices` type is a handle to the topic. It is a generic type that takes two arguments: the event type and the partition map type. The partition map type is used to map events to partitions. In this case, we are using a single partition map, which means that all events are sent to the same partition.

Then define a Sink to consume from the topic:

```go
Expand All @@ -35,10 +39,13 @@ func SendInvoiceEmail(ctx context.Context, in Invoice) error {
}
```

Events can be published to a topic like so:
Events can be published to a topic by injecting the topic type into a verb:

```go
Invoices.Publish(ctx, Invoice{...})
func PublishInvoice(ctx context.Context, topic Invoices) error {
topic.Publish(ctx, Invoice{...})
// ...
}
```

<!-- kotlin -->
Expand Down
26 changes: 19 additions & 7 deletions docs/content/docs/reference/secretsconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ Configuration values are named, typed values. They are managed by the `ftl confi
To declare a configuration value use the following syntax:

```go
var defaultUser = ftl.Config[Username]("defaultUser")
type DefaultUser = ftl.Config[Username]
```

Then to retrieve a configuration value:
Note that the name of the configuration value as represented in the FTL schema is the lower camel case version of the type name.

Configuration values can be injected into FTL methods, such as `@Verb`, HTTP ingress, Cron etc. To inject a configuration value, use the following syntax:

```go
username = defaultUser.Get(ctx)
//ftl:verb
func Hello(ctx context.Context, req Request, defaultUser DefaultUser) error {
username := defaultUser.Get(ctx)
// ...
}
```

<!-- kotlin -->
Expand Down Expand Up @@ -70,13 +76,19 @@ Secrets are encrypted, named, typed values. They are managed by the `ftl secret`
Declare a secret with the following:

```go
var apiKey = ftl.Secret[Credentials]("apiKey")
type ApiKey = ftl.Secret[Credentials]
```

Then to retrieve a secret value:
Like configuration values, the name of the secret as represented in the FTL schema is the lower camel case version of the type name.

Configuration values can be injected into FTL methods, such as `@Verb`, HTTP ingress, Cron etc. To inject a configuration value, use the following syntax:

```go
key = apiKey.Get(ctx)
//ftl:verb
func CallApi(ctx context.Context, req Request, apiKey ApiKey) error {
credentials := apiKey.Get(ctx)
// ...
}
```

<!-- kotlin -->
Expand Down Expand Up @@ -113,4 +125,4 @@ var client = ftl.Map(ftl.Secret[Credentials]("credentials"),
})
```

This is not currently supported in Kotlin or Java.
This is not currently supported in Kotlin or Java.

0 comments on commit 7e48800

Please sign in to comment.