Skip to content

Commit 783b811

Browse files
Merge pull request #128 from intelops/restructure-rest-grpc-ws-servers
Enhancement: Restructure rest grpc ws servers
2 parents 6dd3bc7 + d35c405 commit 783b811

File tree

118 files changed

+7064
-4047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+7064
-4047
lines changed

.github/workflows/core-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@ jobs:
3737
cd core
3838
golangci-lint run
3939
cd ..
40+
- name: Install Protoc
41+
uses: arduino/setup-protoc@v2
42+
with:
43+
version: "23.x"
4044
- name: Test
4145
run: |
4246
cd core
47+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
48+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
49+
export GOPATH=$HOME/go
50+
export GOBIN=$GOPATH/bin
51+
export PATH=$PATH:$GOROOT:$GOBIN
4352
go test -v ./... -race -coverprofile=coverage.out -coverpkg=./... -covermode=atomic
4453
cd ..
4554
- name: Upload coverage to Codecov

app/src/routes/models.ts

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,66 @@ export interface Resource {
44
fields: Map<string, Map<string, string>>;
55
}
66

7-
interface RestServerConfig {
7+
export interface RestConfig {
88
template: string;
9+
framework: string;
10+
server: {
11+
port: string;
12+
sqlDb: string;
13+
resources?: Resource[];
14+
openApiFileYamlContent?: string;
15+
};
16+
clients: RestClient[];
17+
}
18+
19+
export interface RestClient {
20+
sourceNodeName: string;
21+
sourceNodeId: string;
922
port: string;
10-
framework?: string;
11-
sqlDb: string;
12-
resources?: Resource[];
13-
openApiFileYamlContent?: string;
1423
}
1524

16-
export interface GrpcServerConfig {
25+
export interface GrpcConfig {
26+
template: string;
27+
framework: string;
28+
server?: {
29+
port?: string;
30+
sqlDb?: string;
31+
resources?: Resource[];
32+
protoFileContent?: string;
33+
};
34+
clients?: GrpcClient[];
35+
}
36+
37+
export interface GrpcClient {
38+
sourceNodeName: string;
39+
sourceNodeId: string;
1740
port: string;
18-
framework?: string;
19-
resources?: Resource[];
20-
protoFileContent?: string;
2141
}
2242

23-
export interface WsServerConfig {
43+
export interface WsConfig {
44+
template: string;
45+
framework: string;
46+
server?: {
47+
port?: string;
48+
resources?: Resource[];
49+
};
50+
clients?: WsClient[];
51+
}
52+
53+
export interface WsClient {
54+
sourceNodeName: string;
55+
sourceNodeId: string;
2456
port: string;
25-
framework?: string;
26-
resources?: Resource[];
2757
}
2858

2959
export interface NodeConsumerData {
3060
name: string;
31-
restServerConfig: RestServerConfig;
32-
grpcServerConfig: GrpcServerConfig;
33-
wsServerConfig: WsServerConfig;
61+
restConfig?: RestConfig;
62+
grpcConfig?: GrpcConfig;
63+
wsConfig?: WsConfig;
3464
language: string;
35-
metadata?: Map<string, string>;
36-
annotations?: Map<string, string>;
65+
metadata: Map<string, string>;
66+
annotations: Map<string, string>;
3767
}
3868

3969
export interface CompageNode {
@@ -42,24 +72,8 @@ export interface CompageNode {
4272
consumerData: NodeConsumerData;
4373
}
4474

45-
export interface RestClientConfig {
46-
port: string;
47-
}
48-
49-
export interface GrpcClientConfig {
50-
port: string;
51-
}
52-
53-
export interface WsClientConfig {
54-
port: string;
55-
}
56-
5775
export interface EdgeConsumerData {
5876
name: string;
59-
externalNode: string;
60-
restClientConfig: RestClientConfig;
61-
grpcClientConfig: GrpcClientConfig;
62-
wsClientConfig: WsClientConfig;
6377
metadata?: Map<string, string>;
6478
annotations?: Map<string, string>;
6579
}

app/src/routes/projects-operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const updateToGithub = (projectEntity: ProjectEntity, response: Response)
119119
base64Json,
120120
'updated project from ui',
121121
sha).then(res => {
122-
Logger.debug(`commitCompageJson Response: ${res.data}`);
122+
Logger.debug(`commitCompageJson Response: ${JSON.stringify(res.data)}`);
123123
const message = `An update to .compage/config.json in Repository for '${projectEntity.displayName}' is committed, '${projectEntity.displayName}' is updated successfully`;
124124
Logger.info(message);
125125
return response.status(200).json(getUpdateProjectResponse(projectEntity, message));

core/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.dockerignore
2+
**/*.log
3+
Dockerfile
4+
.git
5+
.gitignore

core/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflag
1818
CMD ["go", "run", "main.go"]
1919

2020
################ Production ################
21-
FROM openjdk:8-jdk-alpine3.9
21+
FROM alpine:3.18.2
2222
# Create project directory (workdir)
2323
WORKDIR /app
2424

25+
RUN apk update && apk add protoc && apk add openjdk8
2526
RUN apk update && apk add bash && apk add curl && apk add jq && apk add --update go \
2627
&& curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh \
2728
> /app/openapi-generator-cli \

core/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ require (
88
github.com/sirupsen/logrus v1.9.0
99
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
1010
golang.org/x/text v0.9.0
11-
google.golang.org/grpc v1.53.0
12-
google.golang.org/protobuf v1.28.1
11+
google.golang.org/grpc v1.56.0
12+
google.golang.org/protobuf v1.30.0
1313
)
1414

1515
require (
16-
github.com/golang/protobuf v1.5.2 // indirect
16+
github.com/golang/protobuf v1.5.3 // indirect
1717
github.com/stretchr/testify v1.8.1 // indirect
1818
golang.org/x/net v0.9.0 // indirect
1919
golang.org/x/sys v0.7.0 // indirect
20-
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
20+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
2121
)

core/go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
44
github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlLgiA=
55
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
66
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
7-
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
8-
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
7+
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
8+
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
99
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1010
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
1111
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
@@ -32,14 +32,14 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3232
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
3333
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
3434
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
35-
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
36-
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
37-
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
38-
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
35+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
36+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
37+
google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE=
38+
google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
3939
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
4040
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
41-
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
42-
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
41+
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
42+
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
4343
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4444
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4545
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

core/internal/converter/converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func validate(compageJSON *core.CompageJSON) error {
8383
n.ConsumerData.Language = languages.Go
8484
}
8585
// set default template as compage
86-
if n.ConsumerData.RestServerConfig != nil && n.ConsumerData.RestServerConfig.Template == "" {
87-
n.ConsumerData.RestServerConfig.Template = templates.Compage
86+
if n.ConsumerData.RestConfig != nil && n.ConsumerData.RestConfig.Template == "" {
87+
n.ConsumerData.RestConfig.Template = templates.Compage
8888
}
8989
}
9090

core/internal/core/edge/edge.go

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
1-
package edge
1+
package coreedge
22

33
// Edge can have connection details such as port (Assumption is that the port mentioned is of SRC in edge)
44
type Edge struct {
5-
Dest string `json:"dest"`
6-
ID string `json:"id"`
7-
Src string `json:"src"`
8-
ConsumerData ConsumerData `json:"consumerData,omitempty"`
5+
Dest string `json:"dest"`
6+
ID string `json:"id"`
7+
Src string `json:"src"`
8+
ConsumerData EdgeConsumerData `json:"consumerData,omitempty"`
99
}
1010

11-
// ConsumerData has detailed attributes of an edge
12-
type ConsumerData struct {
13-
RestClientConfig *RestClientConfig `json:"restClientConfig,omitempty"`
14-
GrpcClientConfig *GrpcClientConfig `json:"grpcClientConfig,omitempty"`
15-
WsClientConfig *WsClientConfig `json:"wsClientConfig,omitempty"`
16-
Metadata map[string]interface{} `json:"metadata,omitempty"`
17-
Annotations map[string]string `json:"annotations,omitempty"`
18-
ExternalNode string `json:"externalNode,omitempty"`
19-
Name string `json:"name"`
20-
}
21-
22-
// RestClientConfig holds information for an edge for rest protocol.
23-
type RestClientConfig struct {
24-
Port string `json:"port"`
25-
}
26-
27-
// GrpcClientConfig holds information for an edge for grpc protocol.
28-
type GrpcClientConfig struct {
29-
Port string `json:"port"`
30-
}
31-
32-
// WsClientConfig holds information for an edge for ws protocol.
33-
type WsClientConfig struct {
34-
Port string `json:"port"`
11+
// EdgeConsumerData has detailed attributes of an edge
12+
type EdgeConsumerData struct {
13+
Metadata map[string]interface{} `json:"metadata,omitempty"`
14+
Annotations map[string]string `json:"annotations,omitempty"`
15+
Name string `json:"name"`
3516
}

core/internal/core/models.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package core
22

33
import (
4-
"github.com/intelops/compage/core/internal/core/edge"
5-
"github.com/intelops/compage/core/internal/core/node"
4+
coreedge "github.com/intelops/compage/core/internal/core/edge"
5+
corenode "github.com/intelops/compage/core/internal/core/node"
66
"time"
77
)
88

@@ -28,9 +28,9 @@ type Project struct {
2828
// CompageJSON has all edges and nodes
2929
type CompageJSON struct {
3030
// Linkages (connection details) between Nodes
31-
Edges []*edge.Edge `json:"edges"`
31+
Edges []*coreedge.Edge `json:"edges"`
3232
// Nodes represent components and has details of the component.
33-
Nodes []*node.Node `json:"nodes"`
33+
Nodes []*corenode.Node `json:"nodes"`
3434
}
3535

3636
// Rest Protocol

0 commit comments

Comments
 (0)