OSDN Git Service

add package
[bytom/vapor.git] / vendor / github.com / hashicorp / go-plugin / examples / grpc / README.md
1 # KV Example
2
3 This example builds a simple key/value store CLI where the mechanism
4 for storing and retrieving keys is pluggable. To build this example:
5
6 ```sh
7 # This builds the main CLI
8 $ go build -o kv
9
10 # This builds the plugin written in Go
11 $ go build -o kv-go-grpc ./plugin-go-grpc
12
13 # This tells the KV binary to use the "kv-go-grpc" binary
14 $ export KV_PLUGIN="./kv-go-grpc"
15
16 # Read and write
17 $ ./kv put hello world
18
19 $ ./kv get hello
20 world
21 ```
22
23 ### Plugin: plugin-go-grpc
24
25 This plugin uses gRPC to serve a plugin that is written in Go:
26
27 ```
28 # This builds the plugin written in Go
29 $ go build -o kv-go-grpc ./plugin-go-grpc
30
31 # This tells the KV binary to use the "kv-go-grpc" binary
32 $ export KV_PLUGIN="./kv-go-grpc"
33 ```
34
35 ### Plugin: plugin-go-netrpc
36
37 This plugin uses the builtin Go net/rpc mechanism to serve the plugin:
38
39 ```
40 # This builds the plugin written in Go
41 $ go build -o kv-go-netrpc ./plugin-go-netrpc
42
43 # This tells the KV binary to use the "kv-go-netrpc" binary
44 $ export KV_PLUGIN="./kv-go-netrpc"
45 ```
46
47 ### Plugin: plugin-python
48
49 This plugin is written in Python:
50
51 ```
52 $ export KV_PLUGIN="python plugin-python/plugin.py"
53 ```
54
55 ## Updating the Protocol
56
57 If you update the protocol buffers file, you can regenerate the file
58 using the following command from this directory. You do not need to run
59 this if you're just trying the example.
60
61 For Go:
62
63 ```sh
64 $ protoc -I proto/ proto/kv.proto --go_out=plugins=grpc:proto/
65 ```
66
67 For Python:
68
69 ```sh
70 $ python -m grpc_tools.protoc -I ./proto/ --python_out=./plugin-python/ --grpc_python_out=./plugin-python/ ./proto/kv.proto
71 ```