Skip to content

Commit

Permalink
Prepend '::' to Twirp::Service and Twirp::Client to prevent namespace…
Browse files Browse the repository at this point in the history
… collisions
  • Loading branch information
etipton committed Mar 1, 2022
1 parent 04f041a commit f408d65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions example/hello_world/service_twirp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

module Example
module HelloWorld
class HelloWorldService < Twirp::Service
class HelloWorldService < ::Twirp::Service
package 'example.hello_world'
service 'HelloWorld'
rpc :Hello, HelloRequest, HelloResponse, :ruby_method => :hello
end

class HelloWorldClient < Twirp::Client
class HelloWorldClient < ::Twirp::Client
client_for HelloWorldService
end
end
Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-twirp_ruby/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (g *generator) generateRubyCode(file *descriptor.FileDescriptorProto, pbFil
for i, service := range file.Service {
svcName := service.GetName()

print(b, "%sclass %sService < Twirp::Service", indent, camelCase(svcName))
print(b, "%sclass %sService < ::Twirp::Service", indent, camelCase(svcName))
if pkgName != "" {
print(b, "%s package '%s'", indent, pkgName)
}
Expand All @@ -123,7 +123,7 @@ func (g *generator) generateRubyCode(file *descriptor.FileDescriptorProto, pbFil
print(b, "%send", indent)
print(b, "")

print(b, "%sclass %sClient < Twirp::Client", indent, camelCase(svcName))
print(b, "%sclass %sClient < ::Twirp::Client", indent, camelCase(svcName))
print(b, "%s client_for %sService", indent, camelCase(svcName))
print(b, "%send", indent)
if i < len(file.Service)-1 {
Expand Down

0 comments on commit f408d65

Please sign in to comment.