4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
25 "github.com/apache/thrift/lib/go/thrift"
30 fmt.Fprint(os.Stderr, "Usage of ", os.Args[0], ":\n")
32 fmt.Fprint(os.Stderr, "\n")
37 server := flag.Bool("server", false, "Run server")
38 protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)")
39 framed := flag.Bool("framed", false, "Use framed transport")
40 buffered := flag.Bool("buffered", false, "Use buffered transport")
41 addr := flag.String("addr", "localhost:9090", "Address to listen to")
42 secure := flag.Bool("secure", false, "Use tls secure transport")
46 var protocolFactory thrift.TProtocolFactory
49 protocolFactory = thrift.NewTCompactProtocolFactory()
51 protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
53 protocolFactory = thrift.NewTJSONProtocolFactory()
55 protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
57 fmt.Fprint(os.Stderr, "Invalid protocol specified", protocol, "\n")
62 var transportFactory thrift.TTransportFactory
64 transportFactory = thrift.NewTBufferedTransportFactory(8192)
66 transportFactory = thrift.NewTTransportFactory()
70 transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
74 if err := runServer(transportFactory, protocolFactory, *addr, *secure); err != nil {
75 fmt.Println("error running server:", err)
78 if err := runClient(transportFactory, protocolFactory, *addr, *secure); err != nil {
79 fmt.Println("error running client:", err)