Skip to content

Commit

Permalink
Add all interfaces and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoTavares committed Apr 12, 2024
1 parent c5e3ec3 commit 6799415
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
6 changes: 5 additions & 1 deletion rest_gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ This is a go serviced based on the official [grpc-gateway project](https://githu
that compiles opencue's proto files into a go service that provides a REST interface and redirect calls to the
grpc endpoint.

The service is available at http://opencue-gateway.apps.com
## Running the service

Running the service is very simple:
* Read and modify the rest_gateway/Dockerfile according to your environment and build the gateway image using docker.
* Run the image providing the environment variable `CUEBOT_ENDPOINT=your.cuebot.server:8443`

## REST interface

Expand Down
46 changes: 42 additions & 4 deletions rest_gateway/opencue_gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func getEnv(key, fallback string) string {
}

func run() error {
grpcServerEndpoint := getEnv("CUEBOT_ENDPOINT", "opencuetest01.spimageworks.com:8443")
grpcServerEndpoint := getEnv("CUEBOT_ENDPOINT", "opencuetest01.your.test.server:8443")
port := getEnv("REST_PORT", "8448")

ctx := context.Background()
Expand All @@ -32,11 +32,49 @@ func run() error {
// Note: Make sure the gRPC server is running properly and accessible
mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
err := gw.RegisterShowInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if err != nil {
return err

// show.proto
errShow := gw.RegisterShowInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errShow != nil {
return errShow
}

errFrame := gw.RegisterFrameInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errFrame != nil {
return errFrame
}
errGroup := gw.RegisterGroupInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errGroup != nil {
return errGroup
}
errJob := gw.RegisterJobInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errJob != nil {
return errJob
}
errLayer := gw.RegisterLayerInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errLayer != nil {
return errLayer
}

// host.proto
errDeed := gw.RegisterDeedInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errDeed != nil {
return errDeed
}
errHost := gw.RegisterHostInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errHost != nil {
return errHost
}
errOwner := gw.RegisterOwnerInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errOwner != nil {
return errOwner
}
errProc := gw.RegisterProcInterfaceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, opts)
if errProc != nil {
return errProc
}


// Start HTTP server (and proxy calls to gRPC server endpoint)
return http.ListenAndServe(":" + port, mux)
}
Expand Down

0 comments on commit 6799415

Please sign in to comment.