starwars-knit-gateway-go

module
v0.0.0-...-f54d42c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: Apache-2.0

README

🧶 Knit Gateway in Go

Back to top of Tutorial

In this tutorial the Knit gateway is implemented using knit-go, and is made to listen on address http://localhost:8080. Look at the process diagram below to see where the Knit gateway fits into the bigger picture.

The Knit gateway is what puts the magic into a system using Knit. The gateway is called by Knit clients, and based on the clients' queries automatically issues RPCs to the required backend services to evaluate a query. The gateway will automatically batch and parallelize the requests, issue them in the correct order, and flow required data from responses into subsequent requests until a query is fully executed.

%%{ init: { 'flowchart': { 'curve': 'basis' } } }%%
flowchart LR
A[Knit Client] --> B[Knit Gateway]
subgraph r [Knit Relation Service]
    R{{Relation RPCs}}
end
subgraph f [Film Service]
    F{{Film RPCs}}
end
subgraph s [Starship Service]
    S{{Starship RPCs}}
end
B --> R
B --> F
B --> S
style B stroke:#000,stroke-width:3px

How to run the code

To run the Knit gateway service clone the repo using git clone https://github.com/bufbuild/knit.git, then execute the following from the base of the repository (the other services must be running too).

Slack

cd tutorial/starwars-knit-gateway-go/cmd/gateway

go mod tidy
go run gateway.go

# Output
2023/05/01 11:32:49 Knit gateway starting
2023/05/01 11:32:49 Listening on: 127.0.0.1:8080

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL