Skip to content

Commit

Permalink
Force load of deployer topic
Browse files Browse the repository at this point in the history
  • Loading branch information
daemonl committed May 23, 2024
1 parent 305fc1e commit 5c950b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"gopkg.daemonl.com/envconf"

// Forces the Deployer topic to be in the global registry for later lookup.
// This should be replaced with a dynamic lookup when we build one in
// pentops
_ "github.com/pentops/o5-deploy-aws/gen/o5/deployer/v1/deployer_tpb"
)

var Version string
Expand Down Expand Up @@ -130,11 +135,6 @@ func runServe(ctx context.Context) error {
return err
}

err = types.LoadProtoFromFile("./pentops-o5.binpb")
if err != nil {
return err
}

db, err := openDatabase(ctx)
if err != nil {
return err
Expand Down
8 changes: 7 additions & 1 deletion dynamictype/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ func NewTypeRegistry() *TypeRegistry {
}

func (r *TypeRegistry) FindMessageByName(field protoreflect.FullName) (protoreflect.MessageType, error) {
var descriptor protoreflect.MessageDescriptor
descriptor, ok := r.messages[string(field)]

if !ok {
return nil, fmt.Errorf("couldn't find message by name: %s", field)
td, err := protoregistry.GlobalTypes.FindMessageByName(field)
if err != nil {
return nil, fmt.Errorf("couldn't find message by name: %s", field)
}
descriptor = td.Descriptor()
}

msg := dynamicpb.NewMessageType(descriptor)
Expand Down

0 comments on commit 5c950b8

Please sign in to comment.