Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openrpc based api #2371

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmds/modules/api_gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer"
"github.com/threefoldtech/zbus"
"github.com/threefoldtech/zos/pkg/environment"
"github.com/threefoldtech/zos/pkg/rpc"
"github.com/threefoldtech/zos/pkg/stubs"
substrategw "github.com/threefoldtech/zos/pkg/substrate_gateway"
"github.com/threefoldtech/zos/pkg/utils"
Expand All @@ -36,6 +37,11 @@ var Module cli.Command = cli.Command{
Usage: "number of workers `N`",
Value: 1,
},
&cli.UintFlag{
Name: "port",
Usage: "rpc server port",
Value: 3000,
},
},
Action: action,
}
Expand All @@ -44,6 +50,7 @@ func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
port uint = cli.Uint("port")
)

server, err := zbus.NewRedisServer(module, msgBrokerCon, workerNr)
Expand Down Expand Up @@ -98,6 +105,13 @@ func action(cli *cli.Context) error {
}
api.SetupRoutes(router)

go func() {
if err := rpc.Run(ctx, port, manager, redis, msgBrokerCon); err != nil {
log.Error().Err(err).Msg("failed to run rpc server")
return
}
}()

pair, err := id.KeyPair()
if err != nil {
return err
Expand Down
Loading
Loading