A simple command service implement with grpc.
set := cmds.Set{
1: func(s string) error {
if s == "btc" {
fmt.Println("mining")
return nil
}
return fmt.Errorf("wrong")
},
2: func(s string) error {
fmt.Println(s)
return nil
},
}
s := cmds.InitCMDS(set)
addr := ":8080"
s.Run(addr)
credOpt, _ := cmds.CreateCred(*certFile, *keyFile)
addr := ":8080"
s.Run(addr, credOpt)
cli, _ := client.InitClient(addr)
cred, _ := client.CreateCred(*certFile, *serverName)
cli, _ := client.InitClient(addr, cred)
err = cli.Send(1, "btc")
if err != nil {
panic(err)
}
fmt.Println("success")
err = cli.Send(1, "eth")
fmt.Println(err)