Skip to content

Commit

Permalink
Add an example for host functions
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Aug 24, 2022
1 parent addf172 commit efb7b91
Show file tree
Hide file tree
Showing 7 changed files with 1,225 additions and 0 deletions.
112 changes: 112 additions & 0 deletions examples/host-functions/greeting/greet.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions examples/host-functions/greeting/greet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";
package greeting;

option go_package = "github.com/knqyf263/go-plugin/examples/host-functions/greeting";

// The greeting service definition.
// go:plugin type=plugin version=1
service Greeter {
// Sends a greeting
rpc Greet(GreetRequest) returns (GreetReply) {}
}

// The request message containing the user's name.
message GreetRequest {
string name = 1;
}

// The response message containing the greetings
message GreetReply { string message = 1; }

// The host functions embedded into the plugin
// go:plugin type=host
service HostFunctions {
// Sends a HTTP GET request
rpc HttpGet(HttpGetRequest) returns (HttpGetResponse) {}
}

message HttpGetRequest{
string url = 1;
}

message HttpGetResponse {
bytes response = 1;
}
223 changes: 223 additions & 0 deletions examples/host-functions/greeting/greet_host.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit efb7b91

Please sign in to comment.