OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / hashicorp / go-plugin / examples / grpc / main.go
diff --git a/vendor/github.com/hashicorp/go-plugin/examples/grpc/main.go b/vendor/github.com/hashicorp/go-plugin/examples/grpc/main.go
deleted file mode 100644 (file)
index 3ce765d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-package main
-
-import (
-       "fmt"
-       "io/ioutil"
-       "log"
-       "os"
-       "os/exec"
-
-       "github.com/hashicorp/go-plugin"
-       "github.com/hashicorp/go-plugin/examples/grpc/shared"
-)
-
-func main() {
-       // We don't want to see the plugin logs.
-       log.SetOutput(ioutil.Discard)
-
-       // We're a host. Start by launching the plugin process.
-       client := plugin.NewClient(&plugin.ClientConfig{
-               HandshakeConfig: shared.Handshake,
-               Plugins:         shared.PluginMap,
-               Cmd:             exec.Command("sh", "-c", os.Getenv("KV_PLUGIN")),
-               AllowedProtocols: []plugin.Protocol{
-                       plugin.ProtocolNetRPC, plugin.ProtocolGRPC},
-       })
-       defer client.Kill()
-
-       // Connect via RPC
-       rpcClient, err := client.Client()
-       if err != nil {
-               fmt.Println("Error:", err.Error())
-               os.Exit(1)
-       }
-
-       // Request the plugin
-       raw, err := rpcClient.Dispense("kv")
-       if err != nil {
-               fmt.Println("Error:", err.Error())
-               os.Exit(1)
-       }
-
-       // We should have a KV store now! This feels like a normal interface
-       // implementation but is in fact over an RPC connection.
-       kv := raw.(shared.KV)
-       os.Args = os.Args[1:]
-       switch os.Args[0] {
-       case "get":
-               result, err := kv.Get(os.Args[1])
-               if err != nil {
-                       fmt.Println("Error:", err.Error())
-                       os.Exit(1)
-               }
-
-               fmt.Println(string(result))
-
-       case "put":
-               err := kv.Put(os.Args[1], []byte(os.Args[2]))
-               if err != nil {
-                       fmt.Println("Error:", err.Error())
-                       os.Exit(1)
-               }
-
-       default:
-               fmt.Println("Please only use 'get' or 'put'")
-               os.Exit(1)
-       }
-}