Visibility
By default all declarations in FTL are visible only to the module they're declared in. The implicit visibility of types is that of the first verb or other declaration that references it.
Exporting declarations
Exporting a declaration makes it accessible to other modules. Some declarations that are entirely local to a module, such as secrets/config, cannot be exported.
Types that are transitively referenced by an exported declaration will be automatically exported unless they were already defined but unexported. In this case, an error will be raised and the type must be explicitly exported.
The following table describes the go directives used to export the corresponding declaration:
Symbol | Export syntax |
---|---|
Verb | //ftl:verb export |
Data | //ftl:data export |
Enum/Sum type | //ftl:enum export |
Typealias | //ftl:typealias export |
Topic | //ftl:export 1 |
//ftl:verb export
func Verb(ctx context.Context, in In) (Out, error)
//ftl:typealias export
type UserID string
By default, topics do not require any annotations as the declaration itself is sufficient.
For Kotlin the @Export
annotation can be used to export a declaration:
@Verb
@Export
fun time(): TimeResponse {
// ...
}
For Java the @Export
annotation can be used to export a declaration:
@Verb
@Export
TimeResponse time() {
// ...
}