generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24887ee
commit f2778f6
Showing
5 changed files
with
90 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//ftl:module echo | ||
package echo | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/TBD54566975/ftl/go-runtime/ftl" | ||
// Import the FTL SDK. | ||
) | ||
|
||
type EchoRequest struct{} | ||
type EchoResponse struct { | ||
Name string | ||
} | ||
|
||
//ftl:verb | ||
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) { | ||
err := ftl.CallSink(ctx, Sink, SinkRequest{}) | ||
if err != nil { | ||
return EchoResponse{}, err | ||
} | ||
resp, err := ftl.CallSource(ctx, Source) | ||
if err != nil { | ||
return EchoResponse{}, err | ||
} | ||
|
||
name := resp.Name | ||
return EchoResponse{ | ||
Name: name, | ||
}, nil | ||
} | ||
|
||
type SourceResponse struct { | ||
Name string | ||
} | ||
|
||
//ftl:verb | ||
func Source(ctx context.Context) (SourceResponse, error) { | ||
return SourceResponse{ | ||
Name: "source", | ||
}, nil | ||
} | ||
|
||
type SinkRequest struct{} | ||
|
||
//ftl:verb | ||
func Sink(ctx context.Context, req SinkRequest) error { | ||
return nil | ||
} |
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,25 @@ | ||
package ftl.echo | ||
|
||
import ftl.builtin.Empty | ||
import xyz.block.ftl.Context | ||
import xyz.block.ftl.Verb | ||
|
||
data class EchoResponse(val name: String) | ||
|
||
@Verb | ||
fun echo(context: Context, req: Empty): EchoResponse { | ||
context.callSink(::sink, Empty()) | ||
val resp = context.callSource(::source) | ||
return EchoResponse(name = resp.name) | ||
} | ||
|
||
data class SourceResponse(val name: String) | ||
|
||
@Verb | ||
fun source(context: Context): EchoResponse { | ||
return EchoResponse(name = "source") | ||
} | ||
|
||
@Verb | ||
fun sink(context: Context, req: Empty) { | ||
} |