()
| 35 | } |
| 36 | |
| 37 | func main() { |
| 38 | flag.Usage = Usage |
| 39 | server := flag.Bool("server", false, "Run server") |
| 40 | protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)") |
| 41 | framed := flag.Bool("framed", false, "Use framed transport") |
| 42 | buffered := flag.Bool("buffered", false, "Use buffered transport") |
| 43 | addr := flag.String("addr", "localhost:9090", "Address to listen to") |
| 44 | secure := flag.Bool("secure", false, "Use tls secure transport") |
| 45 | |
| 46 | flag.Parse() |
| 47 | |
| 48 | var protocolFactory thrift.TProtocolFactory |
| 49 | switch *protocol { |
| 50 | case "compact": |
| 51 | protocolFactory = thrift.NewTCompactProtocolFactoryConf(nil) |
| 52 | case "simplejson": |
| 53 | protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(nil) |
| 54 | case "json": |
| 55 | protocolFactory = thrift.NewTJSONProtocolFactory() |
| 56 | case "binary", "": |
| 57 | protocolFactory = thrift.NewTBinaryProtocolFactoryConf(nil) |
| 58 | default: |
| 59 | fmt.Fprint(os.Stderr, "Invalid protocol specified", protocol, "\n") |
| 60 | Usage() |
| 61 | os.Exit(1) |
| 62 | } |
| 63 | |
| 64 | var transportFactory thrift.TTransportFactory |
| 65 | cfg := &thrift.TConfiguration{ |
| 66 | TLSConfig: &tls.Config{ |
| 67 | InsecureSkipVerify: true, |
| 68 | }, |
| 69 | } |
| 70 | if *buffered { |
| 71 | transportFactory = thrift.NewTBufferedTransportFactory(8192) |
| 72 | } else { |
| 73 | transportFactory = thrift.NewTTransportFactory() |
| 74 | } |
| 75 | |
| 76 | if *framed { |
| 77 | transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, cfg) |
| 78 | } |
| 79 | |
| 80 | if *server { |
| 81 | if err := runServer(transportFactory, protocolFactory, *addr, *secure); err != nil { |
| 82 | fmt.Println("error running server:", err) |
| 83 | } |
| 84 | } else { |
| 85 | if err := runClient(transportFactory, protocolFactory, *addr, *secure, cfg); err != nil { |
| 86 | fmt.Println("error running client:", err) |
| 87 | } |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected