Skip to content

Commit

Permalink
add metadata retrive method (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
aatarasoff authored Dec 6, 2023
1 parent d11b11a commit 6cfa7c4
Show file tree
Hide file tree
Showing 16 changed files with 2,189 additions and 20 deletions.
124 changes: 124 additions & 0 deletions api/pbuf-registry/v1/entities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,128 @@ message Dependency {

// The tag of the dependency.
string tag = 2;
}

// Package is a proto file package used in a module
message Package {
// The name of the package.
string name = 1;

// The proto files of the package.
repeated ParsedProtoFile proto_files = 2;

// The dependencies of the package.
repeated PackageDependency dependencies = 3;
}

// ParsedProtoFile is a proto file parsed by the registry
// contains information about messages and services in the proto file
message ParsedProtoFile {
// The filename of the proto file.
string filename = 1;

// The messages in the proto file.
repeated Message messages = 2;

// The services in the proto file.
repeated Service services = 3;
}

// Message is a message in a proto file.
message Message {
// The name of the message.
string name = 1;

// The fields of the message.
repeated Field fields = 2;

// The nested messages of the message.
repeated Message nested_messages = 3;

// The nested enums of the message.
repeated Enum nested_enums = 4;
}

// Field is a field in a message.
message Field {
// The name of the field.
string name = 1;

// The message_type of the field.
string message_type = 2;

// The tag of the field.
int32 tag = 3;

// The repeated flag of the field.
bool repeated = 4;

// The map flag of the field.
bool map = 5;

// The oneof flag of the field.
bool oneof = 6;

// The optional flag of the field.
bool optional = 7;

// The required flag of the field.
bool required = 8;

// The one of names of the field
repeated string oneof_names = 9;

// The one of types of the field
repeated string oneof_types = 10;

// The map key type of the field.
string map_key_type = 11;

// The map value type of the field.
string map_value_type = 12;
}

// Enum is an enum in a proto file.
message Enum {
// The name of the enum.
string name = 1;

// The values of the enum.
repeated EnumValue values = 2;
}

// EnumValue is a value in an enum.
message EnumValue {
// The name of the value.
string name = 1;

// The tag of the value.
int32 tag = 2;
}

// Service is a service in a proto file.
message Service {
// The name of the service.
string name = 1;

// The methods of the service.
repeated Method methods = 2;
}

// Method is a method in a service.
message Method {
// The name of the method.
string name = 1;

// The input type of the method.
string input_type = 2;

// The output type of the method.
string output_type = 3;
}

// PackageDependency is a dependency of a package.
message PackageDependency {
// The name of the dependency.
string name = 1;
}
31 changes: 31 additions & 0 deletions api/pbuf-registry/v1/metadata.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
syntax = "proto3";

package pbufregistry.v1;

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

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

// The metadata service must return parsed information
service MetadataService {
rpc GetMetadata(GetMetadataRequest) returns (GetMetadataResponse) {
option (google.api.http) = {
post: "/v1/metadata"
body: "*"
};
}
}

message GetMetadataRequest {
// The module to get metadata for
string name = 1;

// The tag id to get metadata for
string tag = 2;
}

message GetMetadataResponse {
// The packages in the module
repeated Package packages = 1;
}
6 changes: 4 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Launcher struct {
compactionDaemon background.Daemon
protoParsingDaemon background.Daemon
}

func main() {
config.NewLoader().MustLoad()

Expand All @@ -48,6 +49,7 @@ func main() {
registryRepository := data.NewRegistryRepository(pool, logger)
metadataRepository := data.NewMetadataRepository(pool, logger)
registryServer := server.NewRegistryServer(registryRepository, metadataRepository, logger)
metadataServer := server.NewMetadataServer(registryRepository, metadataRepository, logger)

app := kratos.New(
kratos.ID(id),
Expand All @@ -56,8 +58,8 @@ func main() {
kratos.Metadata(map[string]string{}),
kratos.Logger(logger),
kratos.Server(
server.NewGRPCServer(&config.Cfg.Server, registryServer, logger),
server.NewHTTPServer(&config.Cfg.Server, registryServer, logger),
server.NewGRPCServer(&config.Cfg.Server, registryServer, metadataServer, logger),
server.NewHTTPServer(&config.Cfg.Server, registryServer, metadataServer, logger),
server.NewDebugServer(&config.Cfg.Server, logger),
),
)
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
timeout: 10s
retries: 5
pbuf-registry:
image: ghcr.io/pbufio/registry:v0.4.0-wip.2
image: ghcr.io/pbufio/registry:v0.4.0-wip.3
restart: always
depends_on:
- db
Expand Down Expand Up @@ -49,7 +49,7 @@ services:
command: >
sh -c "/app/pbuf-migrations && /app/pbuf-registry"
pbuf-registry-compaction:
image: ghcr.io/pbufio/registry:v0.4.0-wip.2
image: ghcr.io/pbufio/registry:v0.4.0-wip.3
restart: always
depends_on:
- db
Expand All @@ -68,7 +68,7 @@ services:
command: >
sh -c "/app/pbuf-registry compaction"
pbuf-registry-protoparser:
image: ghcr.io/pbufio/registry:v0.4.0-wip.2
image: ghcr.io/pbufio/registry:v0.4.0-wip.3
restart: always
depends_on:
- db
Expand Down
Loading

0 comments on commit 6cfa7c4

Please sign in to comment.