Skip to content

Commit

Permalink
feat: REST Annotations (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen authored Jan 6, 2024
1 parent 8f9a0a9 commit 62de83d
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 50 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ check_pkgx:
exit 1; \
fi
@echo "pkgx is installed."
pkgx --sync

.PHONY: all
all: check_pkgx
pkgx --sync
pkgx killport@latest 7233
sleep 1
all: check_pkgx stop
pkgx temporal@latest server start-dev &
sleep 2
pkgx task@latest run:all

.PHONY: stop
stop:
pkgx killport@latest 7233
sleep 1
pkgx docker-clean stop
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ curl -v http://localhost:8081/temporal.v1beta1.TemporalService/CreateOnboardingW
"name": "Org 1"
},
"profile": {
"name": "Kevin Chen"
"full_name": "Kevin Chen"
}
}
EOF
Expand All @@ -95,7 +95,7 @@ pkgx http POST \
"name": "Org 1"
},
"profile": {
"name": "Kevin Chen"
"full_name": "Kevin Chen"
}
}
'
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/kevinmichaelchen/temporal-saga-grpc
go 1.21.5

require (
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106023353-b0ccffe2bf81.1
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106023353-b0ccffe2bf81.1
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106205504-60998e437501.1
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106205504-60998e437501.1
buf.build/gen/go/kevinmichaelchen/orgapis/connectrpc/go v1.14.0-20240106023354-7971463d1bab.1
buf.build/gen/go/kevinmichaelchen/orgapis/protocolbuffers/go v1.32.0-20240106023354-7971463d1bab.1
buf.build/gen/go/kevinmichaelchen/profileapis/connectrpc/go v1.14.0-20240106023355-4074133bf516.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I=
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106023353-b0ccffe2bf81.1 h1:HXlREx5iasiZ7RLIcM+Sa9KXLfznGMzfRUvtFJPa3pA=
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106023353-b0ccffe2bf81.1/go.mod h1:bH7/XrbxIE+ZFdY12NEIikndXo36yoc7AV6sJDLR/M0=
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106023353-b0ccffe2bf81.1 h1:Bhg6zySqAAGMy8+lw+EhV1iIU/vDoUekSnFKlvFWX3s=
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106023353-b0ccffe2bf81.1/go.mod h1:f0zTv4+cZ3+O0fQx7E6JKpPLhQuUJMkl+M7Ott4b4wo=
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106205504-60998e437501.1 h1:0TszGVkPTm7U/g4gSxpaMpTP69VE8rPTEChk70Qz4sQ=
buf.build/gen/go/kevinmichaelchen/licenseapis/connectrpc/go v1.14.0-20240106205504-60998e437501.1/go.mod h1:G1rlmkINw1TUjL1oRwMxXtp4njBMAXx+N9X0DxVySoA=
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106205504-60998e437501.1 h1:WxWQri+vLlodmxpDZz7nj91vIHeLgStvg5NtOXn/Bg8=
buf.build/gen/go/kevinmichaelchen/licenseapis/protocolbuffers/go v1.32.0-20240106205504-60998e437501.1/go.mod h1:f0zTv4+cZ3+O0fQx7E6JKpPLhQuUJMkl+M7Ott4b4wo=
buf.build/gen/go/kevinmichaelchen/orgapis/connectrpc/go v1.14.0-20240106023354-7971463d1bab.1 h1:AcL7ufchnekd8PUAipa2TUv93Xo07XOExmoL8Ae5J+4=
buf.build/gen/go/kevinmichaelchen/orgapis/connectrpc/go v1.14.0-20240106023354-7971463d1bab.1/go.mod h1:tq6x6ypkRXOLfa/pojKOaoAtdiwaNhK520RwZdnYRMU=
buf.build/gen/go/kevinmichaelchen/orgapis/protocolbuffers/go v1.32.0-20240106023354-7971463d1bab.1 h1:XGdlUgsatFaPXeMj+KSSIBxC+esBQMK6vLvaSV71iYA=
Expand Down
5 changes: 5 additions & 0 deletions idl/licenseapis/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ deps:
repository: protovalidate
commit: e097f827e65240ac9fd4b1158849a8fc
digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad
- remote: buf.build
owner: googleapis
repository: googleapis
commit: a86849a25cc04f4dbe9b15ddddfbc488
digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943
1 change: 1 addition & 0 deletions idl/licenseapis/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: v1
name: buf.build/kevinmichaelchen/licenseapis
deps:
- buf.build/bufbuild/protovalidate:e097f827e65240ac9fd4b1158849a8fc
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
Expand Down
7 changes: 5 additions & 2 deletions idl/licenseapis/license/v1beta1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package license.v1beta1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";

// Service for managing licenses.
Expand All @@ -13,11 +14,13 @@ service LicenseService {
}
// Get a License.
rpc GetLicense(GetLicenseRequest) returns (GetLicenseResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/licenses/{id}";
option idempotency_level = NO_SIDE_EFFECTS;
}
// ListLicenses - Lists Licenses.
rpc ListLicenses(ListLicensesRequest) returns (ListLicensesResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/licenses";
option idempotency_level = NO_SIDE_EFFECTS;
}
}

Expand Down
5 changes: 5 additions & 0 deletions idl/orgapis/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ deps:
repository: protovalidate
commit: e097f827e65240ac9fd4b1158849a8fc
digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad
- remote: buf.build
owner: googleapis
repository: googleapis
commit: a86849a25cc04f4dbe9b15ddddfbc488
digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943
1 change: 1 addition & 0 deletions idl/orgapis/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: v1
name: buf.build/kevinmichaelchen/orgapis
deps:
- buf.build/bufbuild/protovalidate:e097f827e65240ac9fd4b1158849a8fc
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
Expand Down
7 changes: 5 additions & 2 deletions idl/orgapis/org/v1beta1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package org.v1beta1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";

// Service for managing Orgs.
service OrgService {
Expand All @@ -12,11 +13,13 @@ service OrgService {
}
// GetOrg - Gets an Organization.
rpc GetOrg(GetOrgRequest) returns (GetOrgResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/orgs/{id}";
option idempotency_level = NO_SIDE_EFFECTS;
}
// ListOrgs - Lists Organizations.
rpc ListOrgs(ListOrgsRequest) returns (ListOrgsResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/orgs";
option idempotency_level = NO_SIDE_EFFECTS;
}
}

Expand Down
5 changes: 5 additions & 0 deletions idl/profileapis/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ deps:
repository: protovalidate
commit: e097f827e65240ac9fd4b1158849a8fc
digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad
- remote: buf.build
owner: googleapis
repository: googleapis
commit: a86849a25cc04f4dbe9b15ddddfbc488
digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943
1 change: 1 addition & 0 deletions idl/profileapis/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: v1
name: buf.build/kevinmichaelchen/profileapis
deps:
- buf.build/bufbuild/protovalidate:e097f827e65240ac9fd4b1158849a8fc
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
Expand Down
7 changes: 5 additions & 2 deletions idl/profileapis/profile/v1beta1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package profile.v1beta1;

import "buf/validate/validate.proto";
import "google/api/annotations.proto";

// Service for managing Profiles.
service ProfileService {
Expand All @@ -12,11 +13,13 @@ service ProfileService {
}
// GetProfile - Gets a Profile.
rpc GetProfile(GetProfileRequest) returns (GetProfileResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/profiles/{id}";
option idempotency_level = NO_SIDE_EFFECTS;
}
// ListProfiles - Lists Profiles.
rpc ListProfiles(ListProfilesRequest) returns (ListProfilesResponse) {
option idempotency_level = IDEMPOTENT;
option (google.api.http).get = "/profiles";
option idempotency_level = NO_SIDE_EFFECTS;
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/fxmod/connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// CreateModule - The primary function for building an FX module for Connect Go
// APIs.
func CreateModule(opts *ModuleOptions) fx.Option {
return fx.Module("grpc",
return fx.Module("connect",
fx.Provide(
opts.HandlerProvider,
func() *ModuleOptions {
Expand Down
70 changes: 39 additions & 31 deletions taskfiles/run.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
version: '3'

vars:
PORT_ORG: 15432
PORT_PROFILE: 15433
PORT_LICENSE: 15434
PORT_API_ORG: 9091
PORT_API_LICENSE: 9090
PORT_API_PROFILE: 9092
PORT_DB_ORG: 15432
PORT_DB_PROFILE: 15433
PORT_DB_LICENSE: 15434
SCHEMA_ORG: org.hcl
SCHEMA_PROFILE: profile.hcl
SCHEMA_LICENSE: license.hcl
Expand Down Expand Up @@ -44,54 +47,59 @@ tasks:
env:
GRPC_CONNECT_PORT: 8081

service-license:
run: once
int-run-service:
internal: true
deps:
- task: infra
desc: "Runs license service"
cmds:
- pkgx killport 9090
- go run cmd/svc/license/main.go
- "pkgx killport {{ .PORT_API }}"
- "go run cmd/svc/{{ .NAME }}/main.go"
env:
GRPC_CONNECT_PORT: 9090
DB_CONN_STRING: "postgres://postgres:postgrespassword@localhost:{{ .PORT_LICENSE }}/postgres?sslmode=disable"
GRPC_CONNECT_PORT: "{{ .PORT_API }}"
DB_CONN_STRING: "postgres://postgres:postgrespassword@localhost:{{ .PORT_DB }}/postgres?sslmode=disable"

service-license:
run: once
desc: "Runs license service"
cmds:
- task: int-run-service
vars:
PORT_API: "{{ .PORT_API_LICENSE }}"
PORT_DB: "{{ .PORT_DB_LICENSE }}"
NAME: license

service-org:
run: once
deps:
- task: infra
desc: "Runs Org service"
desc: "Runs org service"
cmds:
- pkgx killport 9091
- go run cmd/svc/org/main.go
env:
GRPC_CONNECT_PORT: 9091
DB_CONN_STRING: "postgres://postgres:postgrespassword@localhost:{{ .PORT_ORG }}/postgres?sslmode=disable"
- task: int-run-service
vars:
PORT_API: "{{ .PORT_API_ORG }}"
PORT_DB: "{{ .PORT_DB_ORG }}"
NAME: org

service-profile:
run: once
deps:
- task: infra
desc: "Runs profile service"
cmds:
- pkgx killport 9092
- go run cmd/svc/profile/main.go
env:
GRPC_CONNECT_PORT: 9092
DB_CONN_STRING: "postgres://postgres:postgrespassword@localhost:{{ .PORT_PROFILE }}/postgres?sslmode=disable"
- task: int-run-service
vars:
PORT_API: "{{ .PORT_API_PROFILE }}"
PORT_DB: "{{ .PORT_DB_PROFILE }}"
NAME: profile

inspect:
desc: "Inspect"
cmds:
- task: int-inspect
vars:
PORT: "{{ .PORT_ORG }}"
PORT: "{{ .PORT_DB_ORG }}"
- task: int-inspect
vars:
PORT: "{{ .PORT_PROFILE }}"
PORT: "{{ .PORT_DB_PROFILE }}"
- task: int-inspect
vars:
PORT: "{{ .PORT_LICENSE }}"
PORT: "{{ .PORT_DB_LICENSE }}"

int-inspect:
internal: true
Expand All @@ -106,15 +114,15 @@ tasks:
cmds:
- task: int-migrate
vars:
PORT: "{{ .PORT_ORG }}"
PORT: "{{ .PORT_DB_ORG }}"
SCHEMA_FILE: "{{ .SCHEMA_ORG }}"
- task: int-migrate
vars:
PORT: "{{ .PORT_PROFILE }}"
PORT: "{{ .PORT_DB_PROFILE }}"
SCHEMA_FILE: "{{ .SCHEMA_PROFILE }}"
- task: int-migrate
vars:
PORT: "{{ .PORT_LICENSE }}"
PORT: "{{ .PORT_DB_LICENSE }}"
SCHEMA_FILE: "{{ .SCHEMA_LICENSE }}"

int-migrate:
Expand Down

0 comments on commit 62de83d

Please sign in to comment.