MCPcopy Create free account
hub / github.com/apache/thrift / main

Function main

tutorial/go/src/main.go:37–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func 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}

Callers

nothing calls this directly

Calls 12

NewTJSONProtocolFactoryFunction · 0.92
NewTTransportFactoryFunction · 0.92
UsageFunction · 0.85
runServerFunction · 0.85
runClientFunction · 0.85
StringMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected