generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding missing docs and completions (#4074)
- Loading branch information
1 parent
6d485fa
commit 275cf7f
Showing
15 changed files
with
256 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
Directive for retrying an async operation. | ||
|
||
Any verb called asynchronously (specifically, PubSub subscribers and cron jobs) may specify a basic exponential backoff retry policy. | ||
Any verb called asynchronously (specifically, PubSub subscribers and cron jobs) may specify a basic exponential backoff retry policy. You can optionally specify a catch verb to handle final failures. | ||
|
||
```go | ||
// Basic retry | ||
//ftl:retry 10 5s 1m | ||
func Process(ctx context.Context, in Invoice) error { | ||
// Process with retries | ||
return nil | ||
func processPayment(ctx context.Context, payment Payment) error { | ||
// Process with retries | ||
return nil | ||
} | ||
|
||
// Retry with catch handler | ||
//ftl:retry 5 1s catch recoverPaymentProcessing | ||
func processPayment(ctx context.Context, payment Payment) error { | ||
// Process with retries, failures will be sent to recoverPaymentProcessing verb | ||
return nil | ||
} | ||
|
||
// The catch verb that handles final failures | ||
//ftl:verb | ||
func recoverPaymentProcessing(ctx context.Context, request builtin.CatchRequest[Payment]) error { | ||
// Safely handle final failure of the payment | ||
return nil | ||
} | ||
``` | ||
|
||
See https://block.github.io/ftl/docs/reference/retries/ | ||
--- | ||
|
||
//ftl:retry ${1:attempts} ${2:minBackoff} ${3:maxBackoff} | ||
func ${4:Process}(ctx context.Context, in ${5:Type}) error { | ||
${6:// TODO: Implement} | ||
//ftl:retry ${1:attempts} ${2:minBackoff} ${3:maxBackoff}${4: catch ${5:catchVerb}} | ||
func ${6:process}(ctx context.Context, in ${7:Type}) error { | ||
${8:// TODO: Implement} | ||
return nil | ||
} | ||
|
||
// Optional catch verb handler | ||
//ftl:verb | ||
func ${5:catchVerb}(ctx context.Context, request builtin.CatchRequest[${7:Type}]) error { | ||
${9:// Safely handle final failure} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
Declare a config variable. | ||
Inject a configuration value into a method. | ||
|
||
Configuration values are named, typed values. They are managed by the `ftl config` command-line. | ||
Configuration values can be injected into FTL methods such as @Verb, HTTP ingress, Cron etc. To inject a configuration value, use the following syntax: | ||
|
||
```java | ||
// Will create a config value called "myConfig" in the FTL schema | ||
@Config | ||
public class MyConfig { | ||
private String value; | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
@Verb | ||
HelloResponse hello(HelloRequest helloRequest, @Config("defaultUser") String defaultUser) { | ||
return new HelloResponse("Hello, " + defaultUser); | ||
} | ||
``` | ||
|
||
See https://block.github.io/ftl/docs/reference/secretsconfig/ | ||
--- | ||
|
||
@Config | ||
public class ${1:Name} { | ||
private ${2:Type} value; | ||
|
||
public ${2:Type} getValue() { | ||
return value; | ||
} | ||
} | ||
@Config("${5:configName}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
Directive for retrying an async operation. | ||
|
||
Any verb called asynchronously (specifically, PubSub subscribers and cron jobs) may specify a basic exponential backoff retry policy. | ||
Any verb called asynchronously (specifically, PubSub subscribers and cron jobs) may specify a basic exponential backoff retry policy. You can optionally specify a catch verb to handle final failures. | ||
|
||
```java | ||
// Basic retry | ||
@Retry(attempts = 10, minBackoff = "5s", maxBackoff = "1m") | ||
public class InvoiceProcessor { | ||
public void process(Context ctx, Invoice invoice) throws Exception { | ||
// Process with retries | ||
} | ||
public void processPayment(Payment payment) throws Exception { | ||
// Process with retries | ||
} | ||
|
||
// Retry with catch handler | ||
@Retry(attempts = 5, minBackoff = "1s", catchVerb = "recoverPaymentProcessing") | ||
public void processPayment(Payment payment) throws Exception { | ||
// Process with retries, failures will be sent to recoverPaymentProcessing verb | ||
} | ||
|
||
// The catch verb that handles final failures | ||
@Verb | ||
public void recoverPaymentProcessing(CatchRequest<Payment> req) { | ||
// Safely handle final failure of the payment | ||
} | ||
``` | ||
|
||
See https://block.github.io/ftl/docs/reference/retries/ | ||
--- | ||
|
||
@Retry(attempts = ${1:10}, minBackoff = "${2:5s}", maxBackoff = "${3:1m}") | ||
public class ${4:Processor} { | ||
public void ${5:process}(Context ctx, ${6:Type} input) throws Exception { | ||
${7:// TODO: Implement} | ||
} | ||
@Retry(attempts = ${1:10}, minBackoff = "${2:5s}", maxBackoff = "${3:1m}"${4:, catchVerb = "${5:catchVerb}"}) | ||
public void ${6:process}(${7:Type} input) throws Exception { | ||
${8:// TODO: Implement} | ||
} | ||
|
||
// Optional catch verb handler | ||
@Verb | ||
public void ${5:catchVerb}(CatchRequest<${7:Type}> req) { | ||
${9:// Safely handle final failure} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Inject a secret value into a method. | ||
|
||
Secrets are encrypted, named, typed values. They are managed by the `ftl secret` command-line. To inject a secret value, use the following syntax: | ||
|
||
```java | ||
@Verb | ||
HelloResponse hello(HelloRequest helloRequest, @Secret("apiKey") String apiKey) { | ||
return new HelloResponse("Hello from API: " + apiKey); | ||
} | ||
``` | ||
|
||
See https://block.github.io/ftl/docs/reference/secretsconfig/ | ||
--- | ||
|
||
@Secret("${5:secretName}") |
Oops, something went wrong.