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

     1  # Counter Example
     2  
     3  This example builds a simple key/counter store CLI where the mechanism
     4  for storing and retrieving keys is pluggable. However, in this example we don't
     5  trust the plugin to do the summation work. We use bi-directional plugins to
     6  call back into the main proccess to do the sum of two numbers. To build this example:
     7  
     8  ```sh
     9  # This builds the main CLI
    10  $ go build -o counter
    11  
    12  # This builds the plugin written in Go
    13  $ go build -o counter-go-grpc ./plugin-go-grpc
    14  
    15  # This tells the Counter binary to use the "counter-go-grpc" binary
    16  $ export COUNTER_PLUGIN="./counter-go-grpc"
    17  
    18  # Read and write
    19  $ ./counter put hello 1
    20  $ ./counter put hello 1
    21  
    22  $ ./counter get hello
    23  2
    24  ```
    25  
    26  ### Plugin: plugin-go-grpc
    27  
    28  This plugin uses gRPC to serve a plugin that is written in Go:
    29  
    30  ```
    31  # This builds the plugin written in Go
    32  $ go build -o counter-go-grpc ./plugin-go-grpc
    33  
    34  # This tells the KV binary to use the "kv-go-grpc" binary
    35  $ export COUNTER_PLUGIN="./counter-go-grpc"
    36  ```
    37  
    38  ## Updating the Protocol
    39  
    40  If you update the protocol buffers file, you can regenerate the file
    41  using the following command from this directory. You do not need to run
    42  this if you're just trying the example.
    43  
    44  ```sh
    45  $ buf generate
    46  ```