github.com/hashicorp/go-plugin@v1.6.0/examples/grpc/README.md (about)

     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  $ python -m venv plugin-python/.venv
    53  $ source plugin-python/.venv/bin/activate
    54  $ pip install -r plugin-python/requirements.txt
    55  $ export KV_PLUGIN="python plugin-python/plugin.py"
    56  ```
    57  
    58  ## Updating the Protocol
    59  
    60  If you update the protocol buffers file, you can regenerate the file
    61  using the following command from this directory. You do not need to run
    62  this if you're just trying the example.
    63  
    64  ```sh
    65  $ buf generate
    66  ```