-
Notifications
You must be signed in to change notification settings - Fork 14
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 #186 from mercari/support-overload-plugin
Support overload for cel plugin functions
- Loading branch information
Showing
19 changed files
with
184 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
grpc/federation | ||
*.wasm |
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
Binary file not shown.
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
grpc/federation | ||
*.wasm | ||
grpc-federation.yaml | ||
buf.gen.yaml |
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 was deleted.
Oops, something went wrong.
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,91 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"fmt" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
var bufGenYAML = ` | ||
# Code generated by cmd/config/main.go. DO NOT EDIT! | ||
version: v1 | ||
managed: | ||
enabled: true | ||
plugins: | ||
- plugin: go | ||
out: . | ||
opt: paths=source_relative | ||
- plugin: go-grpc | ||
out: . | ||
opt: paths=source_relative | ||
- plugin: grpc-federation | ||
out: . | ||
opt: | ||
- paths=source_relative | ||
- plugins=file://plugin.wasm:%s | ||
` | ||
|
||
var grpcFederationYAML = ` | ||
# Code generated by cmd/config/main.go. DO NOT EDIT! | ||
imports: | ||
- proto | ||
src: | ||
- proto | ||
out: . | ||
plugins: | ||
- plugin: go | ||
opt: paths=source_relative | ||
- plugin: go-grpc | ||
opt: paths=source_relative | ||
- plugin: grpc-federation | ||
opt: | ||
- paths=source_relative | ||
- plugins=file://plugin.wasm:%s | ||
` | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Fatalf("%+v", err) | ||
} | ||
} | ||
|
||
func run() error { | ||
wasm, err := os.ReadFile(filepath.Join(root(), "plugin.wasm")) | ||
if err != nil { | ||
return err | ||
} | ||
hash := toSha256(wasm) | ||
if err := os.WriteFile( | ||
filepath.Join(root(), "buf.gen.yaml"), | ||
[]byte(fmt.Sprintf(bufGenYAML, hash)), | ||
0o600, | ||
); err != nil { | ||
return err | ||
} | ||
if err := os.WriteFile( | ||
filepath.Join(root(), "grpc-federation.yaml"), | ||
[]byte(fmt.Sprintf(grpcFederationYAML, hash)), | ||
0o600, | ||
); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func toSha256(v []byte) string { | ||
hash := sha256.Sum256(v) | ||
return hex.EncodeToString(hash[:]) | ||
} | ||
|
||
func root() string { | ||
return filepath.Join(curDir(), "..", "..") | ||
} | ||
|
||
func curDir() string { | ||
_, file, _, _ := runtime.Caller(0) //nolint:dogsled | ||
return filepath.Dir(file) | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
grpc/federation | ||
*.wasm |
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
Binary file not shown.
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
9 changes: 9 additions & 0 deletions
9
_examples/18_load/federation/federation_grpc_federation.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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