Skip to content

Commit

Permalink
Add Module's Dependencies (#8)
Browse files Browse the repository at this point in the history
* add module dependencies

* re-organize files
  • Loading branch information
aatarasoff authored Nov 14, 2023
1 parent bdfc0a7 commit 921d438
Show file tree
Hide file tree
Showing 20 changed files with 1,446 additions and 538 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_PATH=api/v1
API_PATH=api/pbuf-registry
REGISTRY_VERSION?=latest

.PHONY: vendor
Expand All @@ -9,7 +9,7 @@ vendor:
.PHONY: vendor-gen
# gen modules
vendor-gen:
buf generate --template buf.modules.gen.yaml --exclude-path ${API_PATH}
buf generate --template buf.modules.gen.yaml --exclude-path ${API_PATH} --exclude-path third_party/google

.PHONY: vendor-all
vendor-all:
Expand Down
35 changes: 35 additions & 0 deletions api/pbuf-registry/v1/entities.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

package pbufregistry.v1;

option go_package = "pbufregistry/api/v1;v1";

// Module is a module registered in the registry.
message Module {
// id is the unique identifier of the module.
string id = 1;

// The name of the module.
string name = 2;

// The tags of the module.
repeated string tags = 3;
}

// ProtoFile is a proto file registered in the registry.
message ProtoFile {
// The filename of the proto file.
string filename = 1;

// The content of the proto file.
string content = 2;
}

// Dependency is a dependency registered in the registry.
message Dependency {
// The name of the dependency.
string name = 1;

// The tag of the dependency.
string tag = 2;
}
50 changes: 30 additions & 20 deletions api/v1/registry.proto → api/pbuf-registry/v1/registry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package pbufregistry.v1;

import "google/api/annotations.proto";
import "pbuf-registry/v1/entities.proto";

option go_package = "pbufregistry/api/v1;v1";

Expand All @@ -18,7 +19,8 @@ service Registry {
// Get a module by name
rpc GetModule(GetModuleRequest) returns (Module) {
option (google.api.http) = {
get: "/v1/modules/{name}"
post: "/v1/modules/get"
body: "*"
};
}

Expand All @@ -33,7 +35,8 @@ service Registry {
// Pull a module tag
rpc PullModule(PullModuleRequest) returns (PullModuleResponse) {
option (google.api.http) = {
get: "/v1/modules/{name}/tags/{tag}"
post: "/v1/modules/pull"
body: "*"
};
}

Expand All @@ -48,14 +51,24 @@ service Registry {
// Delete a module by name
rpc DeleteModule(DeleteModuleRequest) returns (DeleteModuleResponse) {
option (google.api.http) = {
delete: "/v1/modules/{name}"
post: "/v1/modules/delete"
body: "*"
};
}

// Delete a specific module tag
rpc DeleteModuleTag(DeleteModuleTagRequest) returns (DeleteModuleTagResponse) {
option (google.api.http) = {
delete: "/v1/modules/{name}/tags/{tag}"
post: "/v1/modules/tags/delete"
body: "*"
};
}

// Get Module Dependencies
rpc GetModuleDependencies(GetModuleDependenciesRequest) returns (GetModuleDependenciesResponse) {
option (google.api.http) = {
post: "/v1/modules/dependencies"
body: "*"
};
}
}
Expand Down Expand Up @@ -126,6 +139,9 @@ message PushModuleRequest {

// Protofiles
repeated ProtoFile protofiles = 3;

// Dependencies
repeated Dependency dependencies = 4;
}

// DeleteModuleRequest is the request message for DeleteModule.
Expand Down Expand Up @@ -158,23 +174,17 @@ message DeleteModuleTagResponse {
string tag = 2;
}

// Module is a module registered in the registry.
message Module {
// id is the unique identifier of the module.
string id = 1;

// The name of the module.
string name = 2;
// GetModuleDependenciesRequest is the request message for GetModuleDependencies.
message GetModuleDependenciesRequest {
// The name of the module to retrieve
string name = 1;

// The tags of the module.
repeated string tags = 3;
// The tag of the module to retrieve
string tag = 2;
}

// ProtoFile is a proto file registered in the registry.
message ProtoFile {
// The filename of the proto file.
string filename = 1;

// The content of the proto file.
string content = 2;
// GetModuleDependenciesResponse is the response message for GetModuleDependencies.
message GetModuleDependenciesResponse {
// The dependencies of the module.
repeated Dependency dependencies = 1;
}
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/jackc/pgx/v5/pgxpool"
v1 "github.com/pbufio/pbuf-registry/gen/v1"
v1 "github.com/pbufio/pbuf-registry/gen/pbuf-registry/v1"
"github.com/pbufio/pbuf-registry/internal/config"
"github.com/pbufio/pbuf-registry/internal/data"
"github.com/pbufio/pbuf-registry/internal/server"
Expand Down
Loading

0 comments on commit 921d438

Please sign in to comment.