-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from smartcontractkit/feature/BCF-2872-mercury…
…-grpc-dial Support wsrpc --> grpc for Mercury
- Loading branch information
Showing
11 changed files
with
408 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// protoc-gen-go-wsrpcgrpc is a plugin for the Google protocol buffer compiler to | ||
// generate Go code. Install it by building this program and making it | ||
// accessible within your PATH with the name: | ||
// | ||
// protoc-gen-go-wsrpcgrpc | ||
// | ||
// The 'go-wsrpcgrpc' suffix becomes part of the argument for the protocol compiler, | ||
// such that it can be invoked as: | ||
// | ||
// protoc --go-wsrpcgrpc_out=. path/to/file.proto | ||
// | ||
// This generates Go service definitions for the protocol buffer defined by | ||
// file.proto. With that input, the output will be written to: | ||
// | ||
// path/to/file_wsrpc_grpc.pb.go | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"google.golang.org/protobuf/compiler/protogen" | ||
"google.golang.org/protobuf/types/pluginpb" | ||
) | ||
|
||
type strFlags []string | ||
|
||
func (f *strFlags) String() string { | ||
return fmt.Sprintf("%s", *f) | ||
} | ||
|
||
func (f *strFlags) Set(value string) error { | ||
*f = append(*f, value) | ||
|
||
return nil | ||
} | ||
|
||
const version = "0.0.1" | ||
|
||
var clientServices strFlags | ||
|
||
func main() { | ||
showVersion := flag.Bool("version", false, "print the version and exit") | ||
flag.Parse() | ||
if *showVersion { | ||
fmt.Printf("protoc-gen-go-wsrpcgrpc %v\n", version) | ||
|
||
return | ||
} | ||
|
||
var flags flag.FlagSet | ||
flags.Var(&clientServices, "client-services", "Generate Client RPC services for these services") | ||
|
||
protogen.Options{ | ||
ParamFunc: flags.Set, | ||
}.Run(func(gen *protogen.Plugin) error { | ||
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) | ||
for _, f := range gen.Files { | ||
if !f.Generate { | ||
continue | ||
} | ||
generateFile(gen, f) | ||
} | ||
|
||
return nil | ||
}) | ||
} |
Oops, something went wrong.