Skip to content

Commit

Permalink
Rest gateway (#1355)
Browse files Browse the repository at this point in the history
## Summarize your change
Create a service to expose a REST endpoint for the grpc interface. The
motivation behind having a REST endpoint is to create a web version of
cuegui (coming soon).


## How does it work

See the [module
README](https://github.com/AcademySoftwareFoundation/OpenCue/blob/1f3229599a58af64aa9c7feda7657f8fece9c97d/rest_gateway/README.md)
for a full documentation.

---------

Signed-off-by: Diego Tavares <[email protected]>
Co-authored-by: Zachary Fong <[email protected]>
Co-authored-by: Ramon Figueiredo <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent a2ffd1e commit 2c0a97e
Show file tree
Hide file tree
Showing 26 changed files with 666 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ venv*/
.coverage
coverage.xml
htmlcov/
rest_gateway/*.tar\.gz
/.env
.envrc
.vscode
Expand Down
2 changes: 1 addition & 1 deletion VERSION.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0
1.0
2 changes: 2 additions & 0 deletions proto/comment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package comment;
option java_package = "com.imageworks.spcue.grpc.comment";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// The Comment class contains comment data for any entity that supports
// commenting. Currently these are [Job] and [Host].

Expand Down
1 change: 1 addition & 0 deletions proto/criterion.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package criterion;
option java_package = "com.imageworks.spcue.grpc.criterion";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// -------- Primary Message Types --------]

Expand Down
2 changes: 2 additions & 0 deletions proto/cue.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package cue;
option java_package = "com.imageworks.spcue.grpc.cue";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// Core System level objects and methods


Expand Down
2 changes: 2 additions & 0 deletions proto/department.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package department;
option java_package = "com.imageworks.spcue.grpc.department";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

import "task.proto";

// Departments
Expand Down
1 change: 1 addition & 0 deletions proto/depend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package depend;
option java_package = "com.imageworks.spcue.grpc.depend";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// -------- Services --------

Expand Down
1 change: 1 addition & 0 deletions proto/facility.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option java_multiple_files = true;
import "host.proto";
import "subscription.proto";

option go_package = "opencue_gateway/gen/go";

// -------- Services --------

Expand Down
1 change: 1 addition & 0 deletions proto/filter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option java_multiple_files = true;

import "job.proto";

option go_package = "opencue_gateway/gen/go";

// -------- Services --------

Expand Down
1 change: 1 addition & 0 deletions proto/host.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "criterion.proto";
import "job.proto";
import "renderPartition.proto";

option go_package = "opencue_gateway/gen/go";

// -------- Services --------]

Expand Down
2 changes: 2 additions & 0 deletions proto/job.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package job;
option java_package = "com.imageworks.spcue.grpc.job";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

import "comment.proto";
import "depend.proto";
import "limit.proto";
Expand Down
2 changes: 2 additions & 0 deletions proto/limit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package limit;
option java_package = "com.imageworks.spcue.grpc.limit";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// The Limit class contains data that allows users to place limits
// on the maximum number of running frames for a certain type of layer.

Expand Down
1 change: 1 addition & 0 deletions proto/renderPartition.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package renderPartition;
option java_package = "com.imageworks.spcue.grpc.renderpartition";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// -------- Services --------]

Expand Down
2 changes: 2 additions & 0 deletions proto/report.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package report;
option java_package = "com.imageworks.spcue.grpc.report";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

import "host.proto";

// Interface to handle RQD pings.
Expand Down
2 changes: 2 additions & 0 deletions proto/rqd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package rqd;
option java_package = "com.imageworks.spcue.grpc.rqd";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

import "report.proto";

// Interface for issuing commands to an RQD instance.
Expand Down
1 change: 1 addition & 0 deletions proto/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package service;
option java_package = "com.imageworks.spcue.grpc.service";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// Interface for managing Service objects

Expand Down
2 changes: 2 additions & 0 deletions proto/show.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package show;
option java_package = "com.imageworks.spcue.grpc.show";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

import "department.proto";
import "filter.proto";
import "host.proto";
Expand Down
2 changes: 2 additions & 0 deletions proto/subscription.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package subscription;
option java_package = "com.imageworks.spcue.grpc.subscription";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// Subscriptions
// A subscription is what a show sets up when they want to use hosts in
// an allocation.
Expand Down
2 changes: 2 additions & 0 deletions proto/task.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package task;
option java_package = "com.imageworks.spcue.grpc.task";
option java_multiple_files = true;

option go_package = "opencue_gateway/gen/go";

// Tasks
// Tasks are shot priorities for a specific dept

Expand Down
1 change: 1 addition & 0 deletions rest_gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
54 changes: 54 additions & 0 deletions rest_gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM centos7.6-go1.21:latest AS build

RUN yum install -y \
git \
protobuf3-compiler \
&& yum clean all
WORKDIR /app
ENV PATH=$PATH:/root/go/bin:/opt/protobuf3/usr/bin/

# Copy all of the staged files (protos plus go source)
COPY ./proto /app/proto
COPY ./rest_gateway/opencue_gateway /app/opencue_gateway
# COPY ./lib /app/lib


WORKDIR /app/opencue_gateway
RUN go mod init opencue_gateway && go mod tidy

RUN go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
github.com/golang-jwt/jwt/v5 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc

# Generate go grpc code
RUN mkdir -p gen/go && \
protoc -I ../proto/ \
--go_out ./gen/go/ \
--go_opt paths=source_relative \
--go-grpc_out ./gen/go/ \
--go-grpc_opt paths=source_relative \
../proto/*.proto

# Generate grpc-gateway handlers
RUN protoc -I ../proto/ --grpc-gateway_out ./gen/go \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt generate_unbound_methods=true \
../proto/*.proto

# Uncomment this to run go tests
# RUN go test -v

# Build project
RUN go build -o grpc_gateway main.go

FROM centos-7.6.1810:latest
COPY --from=build /app/opencue_gateway/grpc_gateway /app/

# Ensure logs folder is created and has correct permissions
RUN mkdir -p /logs && chmod 755 /logs

EXPOSE 8448
ENTRYPOINT ["/app/grpc_gateway"]
Loading

0 comments on commit 2c0a97e

Please sign in to comment.