コード例 #1
0
ファイル: main.go プロジェクト: visilicon/thrift-go
func main() {
	var err error
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	var transport thrift.TTransport
	transport, err = thrift.NewTSocket(listen)
	if err != nil {
		fmt.Println("error, thrift init!")
		return
	}
	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		fmt.Printf("error %v\n", err)
		return
	}
	client := puller.NewPullerClientFactory(transport, protocolFactory)
	var request puller.Request
	request.UserId = 12398
	request.Payload = "dlrow olleh"
	var response *puller.Response
	response, err = client.Pull(&request)
	if err != nil {
		fmt.Printf("error, response[%v]\n", err)
		return
	}
	fmt.Printf("response:[%v]\n", response)
}
コード例 #2
0
func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
	var transport thrift.TTransport
	var err error
	if secure {
		cfg := new(tls.Config)
		cfg.InsecureSkipVerify = true
		transport, err = thrift.NewTSSLSocket(addr, cfg)
	} else {
		transport, err = thrift.NewTSocket(addr)
	}
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return err
	}
	if transport == nil {
		return fmt.Errorf("Error opening socket, got nil transport. Is server available?")
	}
	transport = transportFactory.GetTransport(transport)
	if transport == nil {
		return fmt.Errorf("Error from transportFactory.GetTransport(), got nil transport. Is server available?")
	}

	err = transport.Open()
	if err != nil {
		return err
	}
	defer transport.Close()

	return handleClient(tutorial.NewCalculatorClientFactory(transport, protocolFactory))
}
コード例 #3
0
// opens a hive connection
func (conn *HiveConnection) Open() error {

	log.Println("creating new hive connection ")
	var transport thrift.TTransport
	var err error
	transport, err = thrift.NewTSocket(conn.Server)
	if err != nil {
		return err
	}
	if transport == nil {
		return errors.New("No TSocket connection?")
	}

	transport.Open()

	// NewTBinaryProtocolTransport(t TTransport) *TBinaryProtocol {
	protocolfac := thrift.NewTBinaryProtocolFactoryDefault()

	//NewThriftHiveClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol)
	conn.Client = thrifthive.NewThriftHiveClientFactory(transport, protocolfac)

	log.Printf("is open? %v", transport.IsOpen())
	name, err := conn.Client.GetName()
	log.Printf("in conn.Open, how is client? %v %v", name, err)

	if conn.Client == nil {
		log.Println("ERROR, no client")
		return errors.New("no client")
	}

	return nil
}
コード例 #4
0
ファイル: client.go プロジェクト: Rheeseyb/thrift
func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string) error {
	var transport thrift.TTransport
	transport, err := thrift.NewTSocket(addr)
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return err
	}
	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		return err
	}
	return handleClient(tutorial.NewCalculatorClientFactory(transport, protocolFactory))
}
コード例 #5
0
ファイル: main.go プロジェクト: y-okubo/thrift-test
func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
	var transport thrift.TTransport
	var err error

	transport, err = thrift.NewTSocket(addr)
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return err
	}

	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		return err
	}

	return handleClient(awesome_service.NewAwesomeServiceClientFactory(transport, protocolFactory))
}
コード例 #6
0
//创建一个thrift的client
func CreateConnection() (interface{}, error) {
	var client *hello.HelloClient
	var transport thrift.TTransport
	transportFactory := thrift.NewTTransportFactory()
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	raw_transport, e1 := thrift.NewTSocket(net.JoinHostPort(CTR_HOST, CTR_HOST_PORT))
	if e1 != nil {
		return client, e1
	}
	transport = transportFactory.GetTransport(raw_transport)
	e2 := transport.Open()
	if e2 != nil {
		return client, e2
	}

	client = hello.NewHelloClientFactory(transport, protocolFactory)
	return client, nil
}
コード例 #7
0
func RunClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
	var transport thrift.TTransport
	var err error
	if secure {
		cfg := new(tls.Config)
		cfg.InsecureSkipVerify = true
		transport, err = thrift.NewTSSLSocket(addr, cfg)
	} else {
		transport, err = thrift.NewTSocket(addr)
	}
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return err
	}
	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		return err
	}
	return HandleClient(addrservice.NewAddressServiceClientFactory(transport, protocolFactory))
}
コード例 #8
0
ファイル: client.go プロジェクト: jamwyatt/Thrift-golang
func runClient(addr string) *ops.ProducerClient {
	var transport thrift.TTransport
	var err error
	socket, err := thrift.NewTSocket(addr)
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return nil
	}
	transportFactory := thrift.NewTTransportFactory()
	if transportFactory == nil {
		fmt.Println("Failed to create new TransportFactory")
		return nil
	}
	transport = transportFactory.GetTransport(socket)
	if err := transport.Open(); err != nil {
		fmt.Println("Failed to connect to", addr)
		return nil
	}
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	return ops.NewProducerClientFactory(transport, protocolFactory)
}
コード例 #9
0
ファイル: client.go プロジェクト: csigo/hbase
// ThriftClientFactory is an thrift Client factory which creates a connection
// that uses a thrift codec.
func ThriftClientFactory(addr string) func() (io.Closer, error) {
	return func() (io.Closer, error) {
		var transport thrift.TTransport
		socketTransport, err := thrift.NewTSocketTimeout(addr, defaultTimeout)
		if err != nil {
			return nil, err
		}
		transport = thrift.NewTFramedTransport(
			thrift.NewTBufferedTransport(socketTransport, defaultBufferSize))
		protocol := thrift.NewTBinaryProtocolFactoryDefault()
		if err := transport.Open(); err != nil {
			return nil, err
		}

		client := NewHbaseClientFactory(transport, protocol)
		return &clientCloser{
			mu:          &sync.Mutex{},
			conn:        socketTransport,
			HbaseClient: client,
		}, nil
	}
}
コード例 #10
0
func (c *ThriftConnection) Open() error {
	if c.connection != nil {
		Logger.Printf("WARNING re-opening thrigt client connection")
	}
	var transport thrift.TTransport
	var err error
	socket, err := thrift.NewTSocket(fmt.Sprintf("%s:%d", c.addr, c.port))
	if err != nil {
		Logger.Printf("Error opening socket: %s", err)
		return err
	}
	transportFactory := thrift.NewTTransportFactory()
	transport = transportFactory.GetTransport(socket)
	if err := transport.Open(); err != nil {
		Logger.Printf("Thrift client failed to connect to: %s:%d: %s", c.addr, c.port, err)
		return err
	}
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	c.connection = messages.NewDataStoreClientFactory(transport, protocolFactory)
	Logger.Printf("Thrift connection: %s:%d connected", c.addr, c.port)
	return nil
}
コード例 #11
0
ファイル: user.go プロジェクト: mvpmvh/DE2
func NewUserService() *services.UserService {
	var transport thrift.TTransport
	var err error

	addr := beego.AppConfig.String("socketAddress")

	if transport, err = thrift.NewTSocket(addr); err != nil {
		panic("Unable to initialize socket!")
	}

	transportFactory := thrift.NewTTransportFactory()
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()

	transport = transportFactory.GetTransport(transport)

	if !transport.IsOpen() {
		if err = transport.Open(); err != nil {
			panic("Unable to open socket!")
		}
	}

	return &services.UserService{user.NewUserServicerClientFactory(transport, protocolFactory)}
}
コード例 #12
0
ファイル: thriftservice.go プロジェクト: kevinhuo88888/o3erp
func RunThriftService(thriftFunc ThriftFunc) (map[string]string, error) {

	//addr := flag.String("addr", "localhost:9090", "Address to listen to")
	//secure := flag.Bool("secure", false, "Use tls secure transport")
	//flag.Parse()
	addr := "localhost:9090"
	secure := true

	var protocolFactory thrift.TProtocolFactory
	protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()

	var transportFactory thrift.TTransportFactory
	transportFactory = thrift.NewTTransportFactory()

	var transport thrift.TTransport
	var err error
	if secure {
		cfg := new(tls.Config)
		cfg.InsecureSkipVerify = true
		transport, err = thrift.NewTSSLSocket(addr, cfg)
	} else {
		transport, err = thrift.NewTSocket(addr)
	}
	if err != nil {
		fmt.Println("Error opening socket:", err)
		return nil, err
	}
	transport = transportFactory.GetTransport(transport)
	defer transport.Close()
	if err := transport.Open(); err != nil {
		return nil, err
	}
	client := thriftlib.NewBaseServiceClientFactory(transport, protocolFactory)

	return thriftFunc(client)
}
コード例 #13
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := tcliservice.NewTCLIServiceClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "OpenSession":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "OpenSession requires 1 args")
			flag.Usage()
		}
		arg60 := flag.Arg(1)
		mbTrans61 := thrift.NewTMemoryBufferLen(len(arg60))
		defer mbTrans61.Close()
		_, err62 := mbTrans61.WriteString(arg60)
		if err62 != nil {
			Usage()
			return
		}
		factory63 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt64 := factory63.GetProtocol(mbTrans61)
		argvalue0 := tcliservice.NewTOpenSessionReq()
		err65 := argvalue0.Read(jsProt64)
		if err65 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.OpenSession(value0))
		fmt.Print("\n")
		break
	case "CloseSession":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CloseSession requires 1 args")
			flag.Usage()
		}
		arg66 := flag.Arg(1)
		mbTrans67 := thrift.NewTMemoryBufferLen(len(arg66))
		defer mbTrans67.Close()
		_, err68 := mbTrans67.WriteString(arg66)
		if err68 != nil {
			Usage()
			return
		}
		factory69 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt70 := factory69.GetProtocol(mbTrans67)
		argvalue0 := tcliservice.NewTCloseSessionReq()
		err71 := argvalue0.Read(jsProt70)
		if err71 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.CloseSession(value0))
		fmt.Print("\n")
		break
	case "GetInfo":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetInfo requires 1 args")
			flag.Usage()
		}
		arg72 := flag.Arg(1)
		mbTrans73 := thrift.NewTMemoryBufferLen(len(arg72))
		defer mbTrans73.Close()
		_, err74 := mbTrans73.WriteString(arg72)
		if err74 != nil {
			Usage()
			return
		}
		factory75 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt76 := factory75.GetProtocol(mbTrans73)
		argvalue0 := tcliservice.NewTGetInfoReq()
		err77 := argvalue0.Read(jsProt76)
		if err77 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetInfo(value0))
		fmt.Print("\n")
		break
	case "ExecuteStatement":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ExecuteStatement requires 1 args")
			flag.Usage()
		}
		arg78 := flag.Arg(1)
		mbTrans79 := thrift.NewTMemoryBufferLen(len(arg78))
		defer mbTrans79.Close()
		_, err80 := mbTrans79.WriteString(arg78)
		if err80 != nil {
			Usage()
			return
		}
		factory81 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt82 := factory81.GetProtocol(mbTrans79)
		argvalue0 := tcliservice.NewTExecuteStatementReq()
		err83 := argvalue0.Read(jsProt82)
		if err83 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.ExecuteStatement(value0))
		fmt.Print("\n")
		break
	case "GetTypeInfo":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetTypeInfo requires 1 args")
			flag.Usage()
		}
		arg84 := flag.Arg(1)
		mbTrans85 := thrift.NewTMemoryBufferLen(len(arg84))
		defer mbTrans85.Close()
		_, err86 := mbTrans85.WriteString(arg84)
		if err86 != nil {
			Usage()
			return
		}
		factory87 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt88 := factory87.GetProtocol(mbTrans85)
		argvalue0 := tcliservice.NewTGetTypeInfoReq()
		err89 := argvalue0.Read(jsProt88)
		if err89 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetTypeInfo(value0))
		fmt.Print("\n")
		break
	case "GetCatalogs":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetCatalogs requires 1 args")
			flag.Usage()
		}
		arg90 := flag.Arg(1)
		mbTrans91 := thrift.NewTMemoryBufferLen(len(arg90))
		defer mbTrans91.Close()
		_, err92 := mbTrans91.WriteString(arg90)
		if err92 != nil {
			Usage()
			return
		}
		factory93 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt94 := factory93.GetProtocol(mbTrans91)
		argvalue0 := tcliservice.NewTGetCatalogsReq()
		err95 := argvalue0.Read(jsProt94)
		if err95 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetCatalogs(value0))
		fmt.Print("\n")
		break
	case "GetSchemas":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetSchemas requires 1 args")
			flag.Usage()
		}
		arg96 := flag.Arg(1)
		mbTrans97 := thrift.NewTMemoryBufferLen(len(arg96))
		defer mbTrans97.Close()
		_, err98 := mbTrans97.WriteString(arg96)
		if err98 != nil {
			Usage()
			return
		}
		factory99 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt100 := factory99.GetProtocol(mbTrans97)
		argvalue0 := tcliservice.NewTGetSchemasReq()
		err101 := argvalue0.Read(jsProt100)
		if err101 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetSchemas(value0))
		fmt.Print("\n")
		break
	case "GetTables":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetTables requires 1 args")
			flag.Usage()
		}
		arg102 := flag.Arg(1)
		mbTrans103 := thrift.NewTMemoryBufferLen(len(arg102))
		defer mbTrans103.Close()
		_, err104 := mbTrans103.WriteString(arg102)
		if err104 != nil {
			Usage()
			return
		}
		factory105 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt106 := factory105.GetProtocol(mbTrans103)
		argvalue0 := tcliservice.NewTGetTablesReq()
		err107 := argvalue0.Read(jsProt106)
		if err107 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetTables(value0))
		fmt.Print("\n")
		break
	case "GetTableTypes":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetTableTypes requires 1 args")
			flag.Usage()
		}
		arg108 := flag.Arg(1)
		mbTrans109 := thrift.NewTMemoryBufferLen(len(arg108))
		defer mbTrans109.Close()
		_, err110 := mbTrans109.WriteString(arg108)
		if err110 != nil {
			Usage()
			return
		}
		factory111 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt112 := factory111.GetProtocol(mbTrans109)
		argvalue0 := tcliservice.NewTGetTableTypesReq()
		err113 := argvalue0.Read(jsProt112)
		if err113 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetTableTypes(value0))
		fmt.Print("\n")
		break
	case "GetColumns":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetColumns requires 1 args")
			flag.Usage()
		}
		arg114 := flag.Arg(1)
		mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114))
		defer mbTrans115.Close()
		_, err116 := mbTrans115.WriteString(arg114)
		if err116 != nil {
			Usage()
			return
		}
		factory117 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt118 := factory117.GetProtocol(mbTrans115)
		argvalue0 := tcliservice.NewTGetColumnsReq()
		err119 := argvalue0.Read(jsProt118)
		if err119 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetColumns(value0))
		fmt.Print("\n")
		break
	case "GetFunctions":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetFunctions requires 1 args")
			flag.Usage()
		}
		arg120 := flag.Arg(1)
		mbTrans121 := thrift.NewTMemoryBufferLen(len(arg120))
		defer mbTrans121.Close()
		_, err122 := mbTrans121.WriteString(arg120)
		if err122 != nil {
			Usage()
			return
		}
		factory123 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt124 := factory123.GetProtocol(mbTrans121)
		argvalue0 := tcliservice.NewTGetFunctionsReq()
		err125 := argvalue0.Read(jsProt124)
		if err125 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetFunctions(value0))
		fmt.Print("\n")
		break
	case "GetOperationStatus":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetOperationStatus requires 1 args")
			flag.Usage()
		}
		arg126 := flag.Arg(1)
		mbTrans127 := thrift.NewTMemoryBufferLen(len(arg126))
		defer mbTrans127.Close()
		_, err128 := mbTrans127.WriteString(arg126)
		if err128 != nil {
			Usage()
			return
		}
		factory129 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt130 := factory129.GetProtocol(mbTrans127)
		argvalue0 := tcliservice.NewTGetOperationStatusReq()
		err131 := argvalue0.Read(jsProt130)
		if err131 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetOperationStatus(value0))
		fmt.Print("\n")
		break
	case "CancelOperation":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CancelOperation requires 1 args")
			flag.Usage()
		}
		arg132 := flag.Arg(1)
		mbTrans133 := thrift.NewTMemoryBufferLen(len(arg132))
		defer mbTrans133.Close()
		_, err134 := mbTrans133.WriteString(arg132)
		if err134 != nil {
			Usage()
			return
		}
		factory135 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt136 := factory135.GetProtocol(mbTrans133)
		argvalue0 := tcliservice.NewTCancelOperationReq()
		err137 := argvalue0.Read(jsProt136)
		if err137 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.CancelOperation(value0))
		fmt.Print("\n")
		break
	case "CloseOperation":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CloseOperation requires 1 args")
			flag.Usage()
		}
		arg138 := flag.Arg(1)
		mbTrans139 := thrift.NewTMemoryBufferLen(len(arg138))
		defer mbTrans139.Close()
		_, err140 := mbTrans139.WriteString(arg138)
		if err140 != nil {
			Usage()
			return
		}
		factory141 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt142 := factory141.GetProtocol(mbTrans139)
		argvalue0 := tcliservice.NewTCloseOperationReq()
		err143 := argvalue0.Read(jsProt142)
		if err143 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.CloseOperation(value0))
		fmt.Print("\n")
		break
	case "GetResultSetMetadata":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetResultSetMetadata requires 1 args")
			flag.Usage()
		}
		arg144 := flag.Arg(1)
		mbTrans145 := thrift.NewTMemoryBufferLen(len(arg144))
		defer mbTrans145.Close()
		_, err146 := mbTrans145.WriteString(arg144)
		if err146 != nil {
			Usage()
			return
		}
		factory147 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt148 := factory147.GetProtocol(mbTrans145)
		argvalue0 := tcliservice.NewTGetResultSetMetadataReq()
		err149 := argvalue0.Read(jsProt148)
		if err149 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetResultSetMetadata(value0))
		fmt.Print("\n")
		break
	case "FetchResults":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "FetchResults requires 1 args")
			flag.Usage()
		}
		arg150 := flag.Arg(1)
		mbTrans151 := thrift.NewTMemoryBufferLen(len(arg150))
		defer mbTrans151.Close()
		_, err152 := mbTrans151.WriteString(arg150)
		if err152 != nil {
			Usage()
			return
		}
		factory153 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt154 := factory153.GetProtocol(mbTrans151)
		argvalue0 := tcliservice.NewTFetchResultsReq()
		err155 := argvalue0.Read(jsProt154)
		if err155 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.FetchResults(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #14
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewAreaSvcClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createArea":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateArea requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg144 := flag.Arg(2)
		mbTrans145 := thrift.NewTMemoryBufferLen(len(arg144))
		defer mbTrans145.Close()
		_, err146 := mbTrans145.WriteString(arg144)
		if err146 != nil {
			Usage()
			return
		}
		factory147 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt148 := factory147.GetProtocol(mbTrans145)
		argvalue1 := services.NewArea()
		err149 := argvalue1.Read(jsProt148)
		if err149 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateArea(value0, value1))
		fmt.Print("\n")
		break
	case "updateArea":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateArea requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg151 := flag.Arg(2)
		mbTrans152 := thrift.NewTMemoryBufferLen(len(arg151))
		defer mbTrans152.Close()
		_, err153 := mbTrans152.WriteString(arg151)
		if err153 != nil {
			Usage()
			return
		}
		factory154 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt155 := factory154.GetProtocol(mbTrans152)
		argvalue1 := services.NewArea()
		err156 := argvalue1.Read(jsProt155)
		if err156 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateArea(value0, value1))
		fmt.Print("\n")
		break
	case "deleteArea":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeleteArea requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg158 := flag.Arg(2)
		mbTrans159 := thrift.NewTMemoryBufferLen(len(arg158))
		defer mbTrans159.Close()
		_, err160 := mbTrans159.WriteString(arg158)
		if err160 != nil {
			Usage()
			return
		}
		factory161 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt162 := factory161.GetProtocol(mbTrans159)
		argvalue1 := services.NewArea()
		err163 := argvalue1.Read(jsProt162)
		if err163 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.DeleteArea(value0, value1))
		fmt.Print("\n")
		break
	case "getAreaById":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetAreaById requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.GetAreaById(value0, value1))
		fmt.Print("\n")
		break
	case "wasHere":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "WasHere requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2, err168 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err168 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.WasHere(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getNearBy":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetNearBy requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg170 := flag.Arg(2)
		mbTrans171 := thrift.NewTMemoryBufferLen(len(arg170))
		defer mbTrans171.Close()
		_, err172 := mbTrans171.WriteString(arg170)
		if err172 != nil {
			Usage()
			return
		}
		factory173 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt174 := factory173.GetProtocol(mbTrans171)
		argvalue1 := services.NewCoordinate()
		err175 := argvalue1.Read(jsProt174)
		if err175 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err176 := (strconv.Atoi(flag.Arg(3)))
		if err176 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		fmt.Print(client.GetNearBy(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getAllAreasInCity":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetAllAreasInCity requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetAllAreasInCity(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #15
0
ファイル: system_service-remote.go プロジェクト: huodon/tyful
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := service.NewSystemServiceClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "ActiveFontUser":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ActiveFontUser requires 2 args")
			flag.Usage()
		}
		tmp0, err28 := (strconv.Atoi(flag.Arg(1)))
		if err28 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		argvalue1 := flag.Arg(2) == "true"
		value1 := argvalue1
		fmt.Print(client.ActiveFontUser(value0, value1))
		fmt.Print("\n")
		break
	case "FindApplyFormByUnit":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "FindApplyFormByUnit requires 1 args")
			flag.Usage()
		}
		tmp0, err30 := (strconv.Atoi(flag.Arg(1)))
		if err30 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.FindApplyFormByUnit(value0))
		fmt.Print("\n")
		break
	case "PushBoxStatus":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "PushBoxStatus requires 1 args")
			flag.Usage()
		}
		arg31 := flag.Arg(1)
		mbTrans32 := thrift.NewTMemoryBufferLen(len(arg31))
		defer mbTrans32.Close()
		_, err33 := mbTrans32.WriteString(arg31)
		if err33 != nil {
			Usage()
			return
		}
		factory34 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt35 := factory34.GetProtocol(mbTrans32)
		argvalue0 := service.NewBoxStatus()
		err36 := argvalue0.Read(jsProt35)
		if err36 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.PushBoxStatus(value0))
		fmt.Print("\n")
		break
	case "DeleteApplyForm":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "DeleteApplyForm requires 1 args")
			flag.Usage()
		}
		tmp0, err37 := (strconv.Atoi(flag.Arg(1)))
		if err37 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.DeleteApplyForm(value0))
		fmt.Print("\n")
		break
	case "ApproveApplyForm":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ApproveApplyForm requires 1 args")
			flag.Usage()
		}
		tmp0, err38 := (strconv.Atoi(flag.Arg(1)))
		if err38 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.ApproveApplyForm(value0))
		fmt.Print("\n")
		break
	case "CreateUnit":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CreateUnit requires 1 args")
			flag.Usage()
		}
		arg39 := flag.Arg(1)
		mbTrans40 := thrift.NewTMemoryBufferLen(len(arg39))
		defer mbTrans40.Close()
		_, err41 := mbTrans40.WriteString(arg39)
		if err41 != nil {
			Usage()
			return
		}
		factory42 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt43 := factory42.GetProtocol(mbTrans40)
		argvalue0 := service.NewUnit()
		err44 := argvalue0.Read(jsProt43)
		if err44 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.CreateUnit(value0))
		fmt.Print("\n")
		break
	case "DeleteUnit":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "DeleteUnit requires 1 args")
			flag.Usage()
		}
		tmp0, err45 := (strconv.Atoi(flag.Arg(1)))
		if err45 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.DeleteUnit(value0))
		fmt.Print("\n")
		break
	case "FindUnitById":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "FindUnitById requires 1 args")
			flag.Usage()
		}
		tmp0, err46 := (strconv.Atoi(flag.Arg(1)))
		if err46 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.FindUnitById(value0))
		fmt.Print("\n")
		break
	case "FindUnitByName":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "FindUnitByName requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2) == "true"
		value1 := argvalue1
		fmt.Print(client.FindUnitByName(value0, value1))
		fmt.Print("\n")
		break
	case "SendSms":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "SendSms requires 2 args")
			flag.Usage()
		}
		tmp0, err49 := (strconv.Atoi(flag.Arg(1)))
		if err49 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.SendSms(value0, value1))
		fmt.Print("\n")
		break
	case "PushOfflineHistory":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "PushOfflineHistory requires 1 args")
			flag.Usage()
		}
		arg51 := flag.Arg(1)
		mbTrans52 := thrift.NewTMemoryBufferLen(len(arg51))
		defer mbTrans52.Close()
		_, err53 := mbTrans52.WriteString(arg51)
		if err53 != nil {
			Usage()
			return
		}
		factory54 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt55 := factory54.GetProtocol(mbTrans52)
		containerStruct0 := service.NewSystemServicePushOfflineHistoryArgs()
		err56 := containerStruct0.ReadField1(jsProt55)
		if err56 != nil {
			Usage()
			return
		}
		argvalue0 := containerStruct0.History
		value0 := argvalue0
		fmt.Print(client.PushOfflineHistory(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #16
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := bolt.NewBoltSchedulerServiceClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "deployComputation":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "DeployComputation requires 1 args")
			flag.Usage()
		}
		arg102 := flag.Arg(1)
		mbTrans103 := thrift.NewTMemoryBufferLen(len(arg102))
		defer mbTrans103.Close()
		_, err104 := mbTrans103.WriteString(arg102)
		if err104 != nil {
			Usage()
			return
		}
		factory105 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt106 := factory105.GetProtocol(mbTrans103)
		argvalue0 := bolt.NewBoltComputationRequest()
		err107 := argvalue0.Read(jsProt106)
		if err107 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.DeployComputation(value0))
		fmt.Print("\n")
		break
	case "getComputationSlug":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetComputationSlug requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetComputationSlug(value0))
		fmt.Print("\n")
		break
	case "registerComputation":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "RegisterComputation requires 1 args")
			flag.Usage()
		}
		arg109 := flag.Arg(1)
		mbTrans110 := thrift.NewTMemoryBufferLen(len(arg109))
		defer mbTrans110.Close()
		_, err111 := mbTrans110.WriteString(arg109)
		if err111 != nil {
			Usage()
			return
		}
		factory112 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt113 := factory112.GetProtocol(mbTrans110)
		argvalue0 := bolt.NewComputationMetadata()
		err114 := argvalue0.Read(jsProt113)
		if err114 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.RegisterComputation(value0))
		fmt.Print("\n")
		break
	case "scaleComputation":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ScaleComputation requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err116 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err116 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.ScaleComputation(value0, value1))
		fmt.Print("\n")
		break
	case "killTask":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "KillTask requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.KillTask(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #17
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewCitySvcClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createCity":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "CreateCity requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		arg191 := flag.Arg(3)
		mbTrans192 := thrift.NewTMemoryBufferLen(len(arg191))
		defer mbTrans192.Close()
		_, err193 := mbTrans192.WriteString(arg191)
		if err193 != nil {
			Usage()
			return
		}
		factory194 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt195 := factory194.GetProtocol(mbTrans192)
		containerStruct2 := services.NewCitySvcCreateCityArgs()
		err196 := containerStruct2.ReadField3(jsProt195)
		if err196 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Coords
		value2 := argvalue2
		fmt.Print(client.CreateCity(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getNearBy":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetNearBy requires 2 args")
			flag.Usage()
		}
		arg197 := flag.Arg(1)
		mbTrans198 := thrift.NewTMemoryBufferLen(len(arg197))
		defer mbTrans198.Close()
		_, err199 := mbTrans198.WriteString(arg197)
		if err199 != nil {
			Usage()
			return
		}
		factory200 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt201 := factory200.GetProtocol(mbTrans198)
		argvalue0 := services.NewCoordinate()
		err202 := argvalue0.Read(jsProt201)
		if err202 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err203 := (strconv.Atoi(flag.Arg(2)))
		if err203 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		fmt.Print(client.GetNearBy(value0, value1))
		fmt.Print("\n")
		break
	case "getAllCities":
		if flag.NArg()-1 != 0 {
			fmt.Fprintln(os.Stderr, "GetAllCities requires 0 args")
			flag.Usage()
		}
		fmt.Print(client.GetAllCities())
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #18
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := servicessync.NewComplaintManagerSyncClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "addComplaint":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "AddComplaint requires 1 args")
			flag.Usage()
		}
		arg779 := flag.Arg(1)
		mbTrans780 := thrift.NewTMemoryBufferLen(len(arg779))
		defer mbTrans780.Close()
		_, err781 := mbTrans780.WriteString(arg779)
		if err781 != nil {
			Usage()
			return
		}
		factory782 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt783 := factory782.GetProtocol(mbTrans780)
		argvalue0 := servicessync.NewComplaint()
		err784 := argvalue0.Read(jsProt783)
		if err784 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.AddComplaint(value0))
		fmt.Print("\n")
		break
	case "getComplaints":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetComplaints requires 6 args")
			flag.Usage()
		}
		argvalue0, err785 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err785 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err786 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err786 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ComplaintType(tmp2)
		value2 := argvalue2
		argvalue3, err787 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err787 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err789 := (strconv.Atoi(flag.Arg(6)))
		if err789 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		fmt.Print(client.GetComplaints(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "updateComplaint":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateComplaint requires 2 args")
			flag.Usage()
		}
		arg790 := flag.Arg(1)
		mbTrans791 := thrift.NewTMemoryBufferLen(len(arg790))
		defer mbTrans791.Close()
		_, err792 := mbTrans791.WriteString(arg790)
		if err792 != nil {
			Usage()
			return
		}
		factory793 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt794 := factory793.GetProtocol(mbTrans791)
		argvalue0 := servicessync.NewComplaint()
		err795 := argvalue0.Read(jsProt794)
		if err795 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err796 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err796 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateComplaint(value0, value1))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #19
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewSearchManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "searchPublicResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "SearchPublicResources requires 9 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.SearchCategory(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.Zone(tmp3)
		value3 := argvalue3
		tmp4, err1256 := (strconv.Atoi(flag.Arg(5)))
		if err1256 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err1257 := (strconv.Atoi(flag.Arg(6)))
		if err1257 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg1258 := flag.Arg(7)
		mbTrans1259 := thrift.NewTMemoryBufferLen(len(arg1258))
		defer mbTrans1259.Close()
		_, err1260 := mbTrans1259.WriteString(arg1258)
		if err1260 != nil {
			Usage()
			return
		}
		factory1261 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1262 := factory1261.GetProtocol(mbTrans1259)
		containerStruct6 := services.NewSearchPublicResourcesArgs()
		err1263 := containerStruct6.ReadField7(jsProt1262)
		if err1263 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg1264 := flag.Arg(8)
		mbTrans1265 := thrift.NewTMemoryBufferLen(len(arg1264))
		defer mbTrans1265.Close()
		_, err1266 := mbTrans1265.WriteString(arg1264)
		if err1266 != nil {
			Usage()
			return
		}
		factory1267 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1268 := factory1267.GetProtocol(mbTrans1265)
		containerStruct7 := services.NewSearchPublicResourcesArgs()
		err1269 := containerStruct7.ReadField8(jsProt1268)
		if err1269 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		arg1270 := flag.Arg(9)
		mbTrans1271 := thrift.NewTMemoryBufferLen(len(arg1270))
		defer mbTrans1271.Close()
		_, err1272 := mbTrans1271.WriteString(arg1270)
		if err1272 != nil {
			Usage()
			return
		}
		factory1273 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1274 := factory1273.GetProtocol(mbTrans1271)
		argvalue8 := services.NewFromInfo()
		err1275 := argvalue8.Read(jsProt1274)
		if err1275 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.SearchPublicResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "searchGroupResources":
		if flag.NArg()-1 != 9 {
			fmt.Fprintln(os.Stderr, "SearchGroupResources requires 9 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err1277 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err1277 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.Zone(tmp3)
		value3 := argvalue3
		tmp4, err1278 := (strconv.Atoi(flag.Arg(5)))
		if err1278 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err1279 := (strconv.Atoi(flag.Arg(6)))
		if err1279 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg1280 := flag.Arg(7)
		mbTrans1281 := thrift.NewTMemoryBufferLen(len(arg1280))
		defer mbTrans1281.Close()
		_, err1282 := mbTrans1281.WriteString(arg1280)
		if err1282 != nil {
			Usage()
			return
		}
		factory1283 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1284 := factory1283.GetProtocol(mbTrans1281)
		containerStruct6 := services.NewSearchGroupResourcesArgs()
		err1285 := containerStruct6.ReadField7(jsProt1284)
		if err1285 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg1286 := flag.Arg(8)
		mbTrans1287 := thrift.NewTMemoryBufferLen(len(arg1286))
		defer mbTrans1287.Close()
		_, err1288 := mbTrans1287.WriteString(arg1286)
		if err1288 != nil {
			Usage()
			return
		}
		factory1289 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1290 := factory1289.GetProtocol(mbTrans1287)
		containerStruct7 := services.NewSearchGroupResourcesArgs()
		err1291 := containerStruct7.ReadField8(jsProt1290)
		if err1291 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		arg1292 := flag.Arg(9)
		mbTrans1293 := thrift.NewTMemoryBufferLen(len(arg1292))
		defer mbTrans1293.Close()
		_, err1294 := mbTrans1293.WriteString(arg1292)
		if err1294 != nil {
			Usage()
			return
		}
		factory1295 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1296 := factory1295.GetProtocol(mbTrans1293)
		argvalue8 := services.NewFromInfo()
		err1297 := argvalue8.Read(jsProt1296)
		if err1297 != nil {
			Usage()
			return
		}
		value8 := argvalue8
		fmt.Print(client.SearchGroupResources(value0, value1, value2, value3, value4, value5, value6, value7, value8))
		fmt.Print("\n")
		break
	case "searchGroup":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "SearchGroup requires 7 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.GroupType(tmp1)
		value1 := argvalue1
		tmp2, err1299 := (strconv.Atoi(flag.Arg(3)))
		if err1299 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1300 := (strconv.Atoi(flag.Arg(4)))
		if err1300 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg1301 := flag.Arg(5)
		mbTrans1302 := thrift.NewTMemoryBufferLen(len(arg1301))
		defer mbTrans1302.Close()
		_, err1303 := mbTrans1302.WriteString(arg1301)
		if err1303 != nil {
			Usage()
			return
		}
		factory1304 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1305 := factory1304.GetProtocol(mbTrans1302)
		containerStruct4 := services.NewSearchGroupArgs()
		err1306 := containerStruct4.ReadField5(jsProt1305)
		if err1306 != nil {
			Usage()
			return
		}
		argvalue4 := containerStruct4.Sortlist
		value4 := argvalue4
		arg1307 := flag.Arg(6)
		mbTrans1308 := thrift.NewTMemoryBufferLen(len(arg1307))
		defer mbTrans1308.Close()
		_, err1309 := mbTrans1308.WriteString(arg1307)
		if err1309 != nil {
			Usage()
			return
		}
		factory1310 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1311 := factory1310.GetProtocol(mbTrans1308)
		containerStruct5 := services.NewSearchGroupArgs()
		err1312 := containerStruct5.ReadField6(jsProt1311)
		if err1312 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Filterlist
		value5 := argvalue5
		arg1313 := flag.Arg(7)
		mbTrans1314 := thrift.NewTMemoryBufferLen(len(arg1313))
		defer mbTrans1314.Close()
		_, err1315 := mbTrans1314.WriteString(arg1313)
		if err1315 != nil {
			Usage()
			return
		}
		factory1316 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1317 := factory1316.GetProtocol(mbTrans1314)
		argvalue6 := services.NewFromInfo()
		err1318 := argvalue6.Read(jsProt1317)
		if err1318 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.SearchGroup(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "searchUser":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SearchUser requires 4 args")
			flag.Usage()
		}
		arg1319 := flag.Arg(1)
		mbTrans1320 := thrift.NewTMemoryBufferLen(len(arg1319))
		defer mbTrans1320.Close()
		_, err1321 := mbTrans1320.WriteString(arg1319)
		if err1321 != nil {
			Usage()
			return
		}
		factory1322 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1323 := factory1322.GetProtocol(mbTrans1320)
		argvalue0 := services.NewUserSearchInfo()
		err1324 := argvalue0.Read(jsProt1323)
		if err1324 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1325 := flag.Arg(2)
		mbTrans1326 := thrift.NewTMemoryBufferLen(len(arg1325))
		defer mbTrans1326.Close()
		_, err1327 := mbTrans1326.WriteString(arg1325)
		if err1327 != nil {
			Usage()
			return
		}
		factory1328 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1329 := factory1328.GetProtocol(mbTrans1326)
		containerStruct1 := services.NewSearchUserArgs()
		err1330 := containerStruct1.ReadField2(jsProt1329)
		if err1330 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Sortlist
		value1 := argvalue1
		arg1331 := flag.Arg(3)
		mbTrans1332 := thrift.NewTMemoryBufferLen(len(arg1331))
		defer mbTrans1332.Close()
		_, err1333 := mbTrans1332.WriteString(arg1331)
		if err1333 != nil {
			Usage()
			return
		}
		factory1334 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1335 := factory1334.GetProtocol(mbTrans1332)
		containerStruct2 := services.NewSearchUserArgs()
		err1336 := containerStruct2.ReadField3(jsProt1335)
		if err1336 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Filterlist
		value2 := argvalue2
		arg1337 := flag.Arg(4)
		mbTrans1338 := thrift.NewTMemoryBufferLen(len(arg1337))
		defer mbTrans1338.Close()
		_, err1339 := mbTrans1338.WriteString(arg1337)
		if err1339 != nil {
			Usage()
			return
		}
		factory1340 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1341 := factory1340.GetProtocol(mbTrans1338)
		argvalue3 := services.NewFromInfo()
		err1342 := argvalue3.Read(jsProt1341)
		if err1342 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SearchUser(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "searchResourceByTag":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "SearchResourceByTag requires 8 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ResourceType(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := services.Zone(tmp2)
		value2 := argvalue2
		tmp3, err1344 := (strconv.Atoi(flag.Arg(4)))
		if err1344 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err1345 := (strconv.Atoi(flag.Arg(5)))
		if err1345 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg1346 := flag.Arg(6)
		mbTrans1347 := thrift.NewTMemoryBufferLen(len(arg1346))
		defer mbTrans1347.Close()
		_, err1348 := mbTrans1347.WriteString(arg1346)
		if err1348 != nil {
			Usage()
			return
		}
		factory1349 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1350 := factory1349.GetProtocol(mbTrans1347)
		containerStruct5 := services.NewSearchResourceByTagArgs()
		err1351 := containerStruct5.ReadField6(jsProt1350)
		if err1351 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Sortlist
		value5 := argvalue5
		arg1352 := flag.Arg(7)
		mbTrans1353 := thrift.NewTMemoryBufferLen(len(arg1352))
		defer mbTrans1353.Close()
		_, err1354 := mbTrans1353.WriteString(arg1352)
		if err1354 != nil {
			Usage()
			return
		}
		factory1355 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1356 := factory1355.GetProtocol(mbTrans1353)
		containerStruct6 := services.NewSearchResourceByTagArgs()
		err1357 := containerStruct6.ReadField7(jsProt1356)
		if err1357 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Filterlist
		value6 := argvalue6
		arg1358 := flag.Arg(8)
		mbTrans1359 := thrift.NewTMemoryBufferLen(len(arg1358))
		defer mbTrans1359.Close()
		_, err1360 := mbTrans1359.WriteString(arg1358)
		if err1360 != nil {
			Usage()
			return
		}
		factory1361 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1362 := factory1361.GetProtocol(mbTrans1359)
		argvalue7 := services.NewFromInfo()
		err1363 := argvalue7.Read(jsProt1362)
		if err1363 != nil {
			Usage()
			return
		}
		value7 := argvalue7
		fmt.Print(client.SearchResourceByTag(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "searchGroupIds":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "SearchGroupIds requires 5 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.Zone(tmp1)
		value1 := argvalue1
		arg1365 := flag.Arg(3)
		mbTrans1366 := thrift.NewTMemoryBufferLen(len(arg1365))
		defer mbTrans1366.Close()
		_, err1367 := mbTrans1366.WriteString(arg1365)
		if err1367 != nil {
			Usage()
			return
		}
		factory1368 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1369 := factory1368.GetProtocol(mbTrans1366)
		containerStruct2 := services.NewSearchGroupIdsArgs()
		err1370 := containerStruct2.ReadField3(jsProt1369)
		if err1370 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Sortlist
		value2 := argvalue2
		arg1371 := flag.Arg(4)
		mbTrans1372 := thrift.NewTMemoryBufferLen(len(arg1371))
		defer mbTrans1372.Close()
		_, err1373 := mbTrans1372.WriteString(arg1371)
		if err1373 != nil {
			Usage()
			return
		}
		factory1374 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1375 := factory1374.GetProtocol(mbTrans1372)
		containerStruct3 := services.NewSearchGroupIdsArgs()
		err1376 := containerStruct3.ReadField4(jsProt1375)
		if err1376 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Filterlist
		value3 := argvalue3
		arg1377 := flag.Arg(5)
		mbTrans1378 := thrift.NewTMemoryBufferLen(len(arg1377))
		defer mbTrans1378.Close()
		_, err1379 := mbTrans1378.WriteString(arg1377)
		if err1379 != nil {
			Usage()
			return
		}
		factory1380 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1381 := factory1380.GetProtocol(mbTrans1378)
		argvalue4 := services.NewFromInfo()
		err1382 := argvalue4.Read(jsProt1381)
		if err1382 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.SearchGroupIds(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "searchTags":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SearchTags requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err1384 := (strconv.Atoi(flag.Arg(2)))
		if err1384 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1385 := (strconv.Atoi(flag.Arg(3)))
		if err1385 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		arg1386 := flag.Arg(4)
		mbTrans1387 := thrift.NewTMemoryBufferLen(len(arg1386))
		defer mbTrans1387.Close()
		_, err1388 := mbTrans1387.WriteString(arg1386)
		if err1388 != nil {
			Usage()
			return
		}
		factory1389 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1390 := factory1389.GetProtocol(mbTrans1387)
		argvalue3 := services.NewFromInfo()
		err1391 := argvalue3.Read(jsProt1390)
		if err1391 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.SearchTags(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #20
0
ファイル: push_manager-remote.go プロジェクト: lei-yu/GOPATH
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewPushManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "enablePushNotification":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "EnablePushNotification requires 4 args")
			flag.Usage()
		}
		argvalue0, err1535 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1535 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		arg1538 := flag.Arg(4)
		mbTrans1539 := thrift.NewTMemoryBufferLen(len(arg1538))
		defer mbTrans1539.Close()
		_, err1540 := mbTrans1539.WriteString(arg1538)
		if err1540 != nil {
			Usage()
			return
		}
		factory1541 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1542 := factory1541.GetProtocol(mbTrans1539)
		argvalue3 := services.NewFromInfo()
		err1543 := argvalue3.Read(jsProt1542)
		if err1543 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.EnablePushNotification(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #21
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := shared.NewSharedServiceClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getStruct":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetStruct requires 1 args")
			flag.Usage()
		}
		tmp0, err4 := (strconv.Atoi(flag.Arg(1)))
		if err4 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := argvalue0
		fmt.Print(client.GetStruct(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #22
0
ファイル: user_ser-remote.go プロジェクト: proudlily/Auth_ser
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := User.NewUserSerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "Register":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "Register requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.Register(value0, value1))
		fmt.Print("\n")
		break
	case "Login":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "Login requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.Login(value0, value1, value2))
		fmt.Print("\n")
		break
	case "Logout":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "Logout requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.Logout(value0, value1))
		fmt.Print("\n")
		break
	case "AppRegister":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "AppRegister requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.AppRegister(value0, value1, value2))
		fmt.Print("\n")
		break
	case "AppLogin":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "AppLogin requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		argvalue3 := flag.Arg(4)
		value3 := argvalue3
		fmt.Print(client.AppLogin(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "AccessToken":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "AccessToken requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.AccessToken(value0, value1))
		fmt.Print("\n")
		break
	case "Authorize":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "Authorize requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		argvalue3 := flag.Arg(4)
		value3 := argvalue3
		fmt.Print(client.Authorize(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "Oauth2Token":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "Oauth2Token requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.Oauth2Token(value0, value1, value2))
		fmt.Print("\n")
		break
	case "UserInfo":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UserInfo requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.UserInfo(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #23
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewUserSvcClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createUser":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CreateUser requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.CreateUser(value0))
		fmt.Print("\n")
		break
	case "getMe":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetMe requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetMe(value0))
		fmt.Print("\n")
		break
	case "getUserById":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetUserById requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.GetUserById(value0, value1))
		fmt.Print("\n")
		break
	case "getFriends":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetFriends requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetFriends(value0))
		fmt.Print("\n")
		break
	case "getFriendRequests":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetFriendRequests requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetFriendRequests(value0))
		fmt.Print("\n")
		break
	case "acceptFriendRequest":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "AcceptFriendRequest requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.AcceptFriendRequest(value0, value1))
		fmt.Print("\n")
		break
	case "declineFriendRequest":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeclineFriendRequest requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.DeclineFriendRequest(value0, value1))
		fmt.Print("\n")
		break
	case "sendFriendRequest":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "SendFriendRequest requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.SendFriendRequest(value0, value1))
		fmt.Print("\n")
		break
	case "setProfile":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "SetProfile requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg114 := flag.Arg(2)
		mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114))
		defer mbTrans115.Close()
		_, err116 := mbTrans115.WriteString(arg114)
		if err116 != nil {
			Usage()
			return
		}
		factory117 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt118 := factory117.GetProtocol(mbTrans115)
		argvalue1 := services.NewProfile()
		err119 := argvalue1.Read(jsProt118)
		if err119 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.SetProfile(value0, value1))
		fmt.Print("\n")
		break
	case "requestToken":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "RequestToken requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.RequestToken(value0, value1))
		fmt.Print("\n")
		break
	case "setAdmin":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SetAdmin requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		fmt.Print(client.SetAdmin(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #24
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := servicessync.NewResourceManagerSyncClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "createResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateResource requires 2 args")
			flag.Usage()
		}
		argvalue0, err313 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err313 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg314 := flag.Arg(2)
		mbTrans315 := thrift.NewTMemoryBufferLen(len(arg314))
		defer mbTrans315.Close()
		_, err316 := mbTrans315.WriteString(arg314)
		if err316 != nil {
			Usage()
			return
		}
		factory317 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt318 := factory317.GetProtocol(mbTrans315)
		argvalue1 := servicessync.NewResource()
		err319 := argvalue1.Read(jsProt318)
		if err319 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateResource(value0, value1))
		fmt.Print("\n")
		break
	case "getResource":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetResource requires 1 args")
			flag.Usage()
		}
		argvalue0, err320 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err320 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetResource(value0))
		fmt.Print("\n")
		break
	case "getResourceInfo":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetResourceInfo requires 1 args")
			flag.Usage()
		}
		argvalue0, err321 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err321 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetResourceInfo(value0))
		fmt.Print("\n")
		break
	case "updateResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateResource requires 2 args")
			flag.Usage()
		}
		arg322 := flag.Arg(1)
		mbTrans323 := thrift.NewTMemoryBufferLen(len(arg322))
		defer mbTrans323.Close()
		_, err324 := mbTrans323.WriteString(arg322)
		if err324 != nil {
			Usage()
			return
		}
		factory325 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt326 := factory325.GetProtocol(mbTrans323)
		argvalue0 := servicessync.NewResource()
		err327 := argvalue0.Read(jsProt326)
		if err327 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err328 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err328 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateResource(value0, value1))
		fmt.Print("\n")
		break
	case "deleteResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeleteResource requires 2 args")
			flag.Usage()
		}
		argvalue0, err329 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err329 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err330 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err330 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.DeleteResource(value0, value1))
		fmt.Print("\n")
		break
	case "shareResource":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "ShareResource requires 4 args")
			flag.Usage()
		}
		arg331 := flag.Arg(1)
		mbTrans332 := thrift.NewTMemoryBufferLen(len(arg331))
		defer mbTrans332.Close()
		_, err333 := mbTrans332.WriteString(arg331)
		if err333 != nil {
			Usage()
			return
		}
		factory334 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt335 := factory334.GetProtocol(mbTrans332)
		argvalue0 := servicessync.NewResource()
		err336 := argvalue0.Read(jsProt335)
		if err336 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg337 := flag.Arg(2)
		mbTrans338 := thrift.NewTMemoryBufferLen(len(arg337))
		defer mbTrans338.Close()
		_, err339 := mbTrans338.WriteString(arg337)
		if err339 != nil {
			Usage()
			return
		}
		factory340 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt341 := factory340.GetProtocol(mbTrans338)
		containerStruct1 := servicessync.NewShareResourceArgs()
		err342 := containerStruct1.ReadField2(jsProt341)
		if err342 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.ShareGroups
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.Zone(tmp2)
		value2 := argvalue2
		argvalue3, err343 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err343 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.ShareResource(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getSharedResources":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "GetSharedResources requires 8 args")
			flag.Usage()
		}
		argvalue0, err344 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err344 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.Zone(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ResourceType(tmp2)
		value2 := argvalue2
		argvalue3, err345 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err345 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err346 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err346 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5, err347 := (strconv.ParseInt(flag.Arg(6), 10, 64))
		if err347 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		argvalue6 := flag.Arg(7) == "true"
		value6 := argvalue6
		tmp7, err349 := (strconv.Atoi(flag.Arg(8)))
		if err349 != nil {
			Usage()
			return
		}
		argvalue7 := int32(tmp7)
		value7 := argvalue7
		fmt.Print(client.GetSharedResources(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "cancelSharedResource":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "CancelSharedResource requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.CancelSharedResource(value0))
		fmt.Print("\n")
		break
	case "getUserResources":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetUserResources requires 7 args")
			flag.Usage()
		}
		argvalue0, err351 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err351 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.ResourceType(tmp1)
		value1 := argvalue1
		argvalue2, err352 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err352 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err353 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err353 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err354 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err354 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err356 := (strconv.Atoi(flag.Arg(7)))
		if err356 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		fmt.Print(client.GetUserResources(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "addComment":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "AddComment requires 1 args")
			flag.Usage()
		}
		arg357 := flag.Arg(1)
		mbTrans358 := thrift.NewTMemoryBufferLen(len(arg357))
		defer mbTrans358.Close()
		_, err359 := mbTrans358.WriteString(arg357)
		if err359 != nil {
			Usage()
			return
		}
		factory360 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt361 := factory360.GetProtocol(mbTrans358)
		argvalue0 := servicessync.NewComment()
		err362 := argvalue0.Read(jsProt361)
		if err362 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.AddComment(value0))
		fmt.Print("\n")
		break
	case "deleteComment":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "DeleteComment requires 4 args")
			flag.Usage()
		}
		argvalue0, err363 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err363 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err364 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err364 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err365 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err365 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err366 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err366 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.DeleteComment(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getComments":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetComments requires 6 args")
			flag.Usage()
		}
		argvalue0, err367 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err367 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err368 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err368 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err369 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err369 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3, err370 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err370 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		tmp5, err372 := (strconv.Atoi(flag.Arg(6)))
		if err372 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		fmt.Print(client.GetComments(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "operateThumb":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "OperateThumb requires 4 args")
			flag.Usage()
		}
		argvalue0, err373 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err373 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err374 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err374 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ThumbType(tmp2)
		value2 := argvalue2
		argvalue3, err375 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err375 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.OperateThumb(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getThumbs":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetThumbs requires 7 args")
			flag.Usage()
		}
		argvalue0, err376 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err376 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err377 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err377 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ThumbType(tmp2)
		value2 := argvalue2
		argvalue3, err378 := (strconv.ParseInt(flag.Arg(4), 10, 64))
		if err378 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		argvalue4, err379 := (strconv.ParseInt(flag.Arg(5), 10, 64))
		if err379 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		tmp6, err381 := (strconv.Atoi(flag.Arg(7)))
		if err381 != nil {
			Usage()
			return
		}
		argvalue6 := int32(tmp6)
		value6 := argvalue6
		fmt.Print(client.GetThumbs(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getResources":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetResources requires 4 args")
			flag.Usage()
		}
		argvalue0, err382 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err382 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err383 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err383 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		tmp3, err385 := (strconv.Atoi(flag.Arg(4)))
		if err385 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		fmt.Print(client.GetResources(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getLatestResourcesByGid":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetLatestResourcesByGid requires 2 args")
			flag.Usage()
		}
		argvalue0, err386 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err386 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err387 := (strconv.Atoi(flag.Arg(2)))
		if err387 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		fmt.Print(client.GetLatestResourcesByGid(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceForOperationPlatform":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetResourceForOperationPlatform requires 1 args")
			flag.Usage()
		}
		argvalue0, err388 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err388 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.GetResourceForOperationPlatform(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #25
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = math.MinInt32 // will become unneeded eventually
	_ = strconv.Atoi
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := service.NewAdServletClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "Sender":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Sender requires 1 args")
			flag.Usage()
		}
		arg10 := flag.Arg(1)
		mbTrans11 := thrift.NewTMemoryBufferLen(len(arg10))
		defer mbTrans11.Close()
		_, err12 := mbTrans11.WriteString(arg10)
		if err12 != nil {
			Usage()
			return
		}
		factory13 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt14 := factory13.GetProtocol(mbTrans11)
		argvalue0 := service.NewReqInfo()
		err15 := argvalue0.Read(jsProt14)
		if err15 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.Sender(value0))
		fmt.Print("\n")
		break
	case "Sender2":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Sender2 requires 1 args")
			flag.Usage()
		}
		arg16 := flag.Arg(1)
		mbTrans17 := thrift.NewTMemoryBufferLen(len(arg16))
		defer mbTrans17.Close()
		_, err18 := mbTrans17.WriteString(arg16)
		if err18 != nil {
			Usage()
			return
		}
		factory19 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt20 := factory19.GetProtocol(mbTrans17)
		argvalue0 := service.NewReqInfo()
		err21 := argvalue0.Read(jsProt20)
		if err21 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.Sender2(value0))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #26
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := servicessync.NewChatManagerSyncClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "deleteChatMessage":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "DeleteChatMessage requires 1 args")
			flag.Usage()
		}
		arg14 := flag.Arg(1)
		mbTrans15 := thrift.NewTMemoryBufferLen(len(arg14))
		defer mbTrans15.Close()
		_, err16 := mbTrans15.WriteString(arg14)
		if err16 != nil {
			Usage()
			return
		}
		factory17 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt18 := factory17.GetProtocol(mbTrans15)
		argvalue0 := servicessync.NewChatMessage()
		err19 := argvalue0.Read(jsProt18)
		if err19 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.DeleteChatMessage(value0))
		fmt.Print("\n")
		break
	case "getChatMessages":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetChatMessages requires 2 args")
			flag.Usage()
		}
		arg20 := flag.Arg(1)
		mbTrans21 := thrift.NewTMemoryBufferLen(len(arg20))
		defer mbTrans21.Close()
		_, err22 := mbTrans21.WriteString(arg20)
		if err22 != nil {
			Usage()
			return
		}
		factory23 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt24 := factory23.GetProtocol(mbTrans21)
		containerStruct0 := servicessync.NewGetChatMessagesArgs()
		err25 := containerStruct0.ReadField1(jsProt24)
		if err25 != nil {
			Usage()
			return
		}
		argvalue0 := containerStruct0.Messages
		value0 := argvalue0
		tmp1, err26 := (strconv.Atoi(flag.Arg(2)))
		if err26 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		fmt.Print(client.GetChatMessages(value0, value1))
		fmt.Print("\n")
		break
	case "getLatestChatMessages":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetLatestChatMessages requires 2 args")
			flag.Usage()
		}
		argvalue0, err27 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err27 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err28 := (strconv.Atoi(flag.Arg(2)))
		if err28 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		fmt.Print(client.GetLatestChatMessages(value0, value1))
		fmt.Print("\n")
		break
	case "getGroupMessages":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "GetGroupMessages requires 5 args")
			flag.Usage()
		}
		argvalue0, err29 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err29 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		argvalue1, err30 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err30 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2, err31 := (strconv.ParseInt(flag.Arg(3), 10, 64))
		if err31 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		tmp4, err33 := (strconv.Atoi(flag.Arg(5)))
		if err33 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		fmt.Print(client.GetGroupMessages(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #27
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := servicessync.NewSearchManagerSyncClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "searchPublicResources":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "SearchPublicResources requires 8 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.SearchCategory(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := servicessync.Zone(tmp3)
		value3 := argvalue3
		tmp4, err463 := (strconv.Atoi(flag.Arg(5)))
		if err463 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err464 := (strconv.Atoi(flag.Arg(6)))
		if err464 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg465 := flag.Arg(7)
		mbTrans466 := thrift.NewTMemoryBufferLen(len(arg465))
		defer mbTrans466.Close()
		_, err467 := mbTrans466.WriteString(arg465)
		if err467 != nil {
			Usage()
			return
		}
		factory468 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt469 := factory468.GetProtocol(mbTrans466)
		containerStruct6 := servicessync.NewSearchPublicResourcesArgs()
		err470 := containerStruct6.ReadField7(jsProt469)
		if err470 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg471 := flag.Arg(8)
		mbTrans472 := thrift.NewTMemoryBufferLen(len(arg471))
		defer mbTrans472.Close()
		_, err473 := mbTrans472.WriteString(arg471)
		if err473 != nil {
			Usage()
			return
		}
		factory474 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt475 := factory474.GetProtocol(mbTrans472)
		containerStruct7 := servicessync.NewSearchPublicResourcesArgs()
		err476 := containerStruct7.ReadField8(jsProt475)
		if err476 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		fmt.Print(client.SearchPublicResources(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "searchGroupResources":
		if flag.NArg()-1 != 8 {
			fmt.Fprintln(os.Stderr, "SearchGroupResources requires 8 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err478 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err478 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.ResourceType(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := servicessync.Zone(tmp3)
		value3 := argvalue3
		tmp4, err479 := (strconv.Atoi(flag.Arg(5)))
		if err479 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		tmp5, err480 := (strconv.Atoi(flag.Arg(6)))
		if err480 != nil {
			Usage()
			return
		}
		argvalue5 := int32(tmp5)
		value5 := argvalue5
		arg481 := flag.Arg(7)
		mbTrans482 := thrift.NewTMemoryBufferLen(len(arg481))
		defer mbTrans482.Close()
		_, err483 := mbTrans482.WriteString(arg481)
		if err483 != nil {
			Usage()
			return
		}
		factory484 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt485 := factory484.GetProtocol(mbTrans482)
		containerStruct6 := servicessync.NewSearchGroupResourcesArgs()
		err486 := containerStruct6.ReadField7(jsProt485)
		if err486 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Sortlist
		value6 := argvalue6
		arg487 := flag.Arg(8)
		mbTrans488 := thrift.NewTMemoryBufferLen(len(arg487))
		defer mbTrans488.Close()
		_, err489 := mbTrans488.WriteString(arg487)
		if err489 != nil {
			Usage()
			return
		}
		factory490 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt491 := factory490.GetProtocol(mbTrans488)
		containerStruct7 := servicessync.NewSearchGroupResourcesArgs()
		err492 := containerStruct7.ReadField8(jsProt491)
		if err492 != nil {
			Usage()
			return
		}
		argvalue7 := containerStruct7.Filterlist
		value7 := argvalue7
		fmt.Print(client.SearchGroupResources(value0, value1, value2, value3, value4, value5, value6, value7))
		fmt.Print("\n")
		break
	case "searchGroup":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "SearchGroup requires 6 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.GroupType(tmp1)
		value1 := argvalue1
		tmp2, err494 := (strconv.Atoi(flag.Arg(3)))
		if err494 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err495 := (strconv.Atoi(flag.Arg(4)))
		if err495 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg496 := flag.Arg(5)
		mbTrans497 := thrift.NewTMemoryBufferLen(len(arg496))
		defer mbTrans497.Close()
		_, err498 := mbTrans497.WriteString(arg496)
		if err498 != nil {
			Usage()
			return
		}
		factory499 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt500 := factory499.GetProtocol(mbTrans497)
		containerStruct4 := servicessync.NewSearchGroupArgs()
		err501 := containerStruct4.ReadField5(jsProt500)
		if err501 != nil {
			Usage()
			return
		}
		argvalue4 := containerStruct4.Sortlist
		value4 := argvalue4
		arg502 := flag.Arg(6)
		mbTrans503 := thrift.NewTMemoryBufferLen(len(arg502))
		defer mbTrans503.Close()
		_, err504 := mbTrans503.WriteString(arg502)
		if err504 != nil {
			Usage()
			return
		}
		factory505 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt506 := factory505.GetProtocol(mbTrans503)
		containerStruct5 := servicessync.NewSearchGroupArgs()
		err507 := containerStruct5.ReadField6(jsProt506)
		if err507 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Filterlist
		value5 := argvalue5
		fmt.Print(client.SearchGroup(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "searchUserBackend":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SearchUserBackend requires 3 args")
			flag.Usage()
		}
		arg508 := flag.Arg(1)
		mbTrans509 := thrift.NewTMemoryBufferLen(len(arg508))
		defer mbTrans509.Close()
		_, err510 := mbTrans509.WriteString(arg508)
		if err510 != nil {
			Usage()
			return
		}
		factory511 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt512 := factory511.GetProtocol(mbTrans509)
		argvalue0 := servicessync.NewUserSearchInfo()
		err513 := argvalue0.Read(jsProt512)
		if err513 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg514 := flag.Arg(2)
		mbTrans515 := thrift.NewTMemoryBufferLen(len(arg514))
		defer mbTrans515.Close()
		_, err516 := mbTrans515.WriteString(arg514)
		if err516 != nil {
			Usage()
			return
		}
		factory517 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt518 := factory517.GetProtocol(mbTrans515)
		containerStruct1 := servicessync.NewSearchUserBackendArgs()
		err519 := containerStruct1.ReadField2(jsProt518)
		if err519 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.Sortlist
		value1 := argvalue1
		arg520 := flag.Arg(3)
		mbTrans521 := thrift.NewTMemoryBufferLen(len(arg520))
		defer mbTrans521.Close()
		_, err522 := mbTrans521.WriteString(arg520)
		if err522 != nil {
			Usage()
			return
		}
		factory523 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt524 := factory523.GetProtocol(mbTrans521)
		containerStruct2 := servicessync.NewSearchUserBackendArgs()
		err525 := containerStruct2.ReadField3(jsProt524)
		if err525 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Filterlist
		value2 := argvalue2
		fmt.Print(client.SearchUserBackend(value0, value1, value2))
		fmt.Print("\n")
		break
	case "searchResourceByTag":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "SearchResourceByTag requires 7 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.ResourceType(tmp1)
		value1 := argvalue1
		tmp2, err := (strconv.Atoi(flag.Arg(3)))
		if err != nil {
			Usage()
			return
		}
		argvalue2 := servicessync.Zone(tmp2)
		value2 := argvalue2
		tmp3, err527 := (strconv.Atoi(flag.Arg(4)))
		if err527 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err528 := (strconv.Atoi(flag.Arg(5)))
		if err528 != nil {
			Usage()
			return
		}
		argvalue4 := int32(tmp4)
		value4 := argvalue4
		arg529 := flag.Arg(6)
		mbTrans530 := thrift.NewTMemoryBufferLen(len(arg529))
		defer mbTrans530.Close()
		_, err531 := mbTrans530.WriteString(arg529)
		if err531 != nil {
			Usage()
			return
		}
		factory532 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt533 := factory532.GetProtocol(mbTrans530)
		containerStruct5 := servicessync.NewSearchResourceByTagArgs()
		err534 := containerStruct5.ReadField6(jsProt533)
		if err534 != nil {
			Usage()
			return
		}
		argvalue5 := containerStruct5.Sortlist
		value5 := argvalue5
		arg535 := flag.Arg(7)
		mbTrans536 := thrift.NewTMemoryBufferLen(len(arg535))
		defer mbTrans536.Close()
		_, err537 := mbTrans536.WriteString(arg535)
		if err537 != nil {
			Usage()
			return
		}
		factory538 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt539 := factory538.GetProtocol(mbTrans536)
		containerStruct6 := servicessync.NewSearchResourceByTagArgs()
		err540 := containerStruct6.ReadField7(jsProt539)
		if err540 != nil {
			Usage()
			return
		}
		argvalue6 := containerStruct6.Filterlist
		value6 := argvalue6
		fmt.Print(client.SearchResourceByTag(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "searchGroupIds":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SearchGroupIds requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := servicessync.Zone(tmp1)
		value1 := argvalue1
		arg542 := flag.Arg(3)
		mbTrans543 := thrift.NewTMemoryBufferLen(len(arg542))
		defer mbTrans543.Close()
		_, err544 := mbTrans543.WriteString(arg542)
		if err544 != nil {
			Usage()
			return
		}
		factory545 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt546 := factory545.GetProtocol(mbTrans543)
		containerStruct2 := servicessync.NewSearchGroupIdsArgs()
		err547 := containerStruct2.ReadField3(jsProt546)
		if err547 != nil {
			Usage()
			return
		}
		argvalue2 := containerStruct2.Sortlist
		value2 := argvalue2
		arg548 := flag.Arg(4)
		mbTrans549 := thrift.NewTMemoryBufferLen(len(arg548))
		defer mbTrans549.Close()
		_, err550 := mbTrans549.WriteString(arg548)
		if err550 != nil {
			Usage()
			return
		}
		factory551 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt552 := factory551.GetProtocol(mbTrans549)
		containerStruct3 := servicessync.NewSearchGroupIdsArgs()
		err553 := containerStruct3.ReadField4(jsProt552)
		if err553 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Filterlist
		value3 := argvalue3
		fmt.Print(client.SearchGroupIds(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #28
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := notestore.NewNoteStoreClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getSyncState":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetSyncState requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetSyncState(value0))
		fmt.Print("\n")
		break
	case "getSyncStateWithMetrics":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetSyncStateWithMetrics requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg194 := flag.Arg(2)
		mbTrans195 := thrift.NewTMemoryBufferLen(len(arg194))
		defer mbTrans195.Close()
		_, err196 := mbTrans195.WriteString(arg194)
		if err196 != nil {
			Usage()
			return
		}
		factory197 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt198 := factory197.GetProtocol(mbTrans195)
		argvalue1 := notestore.NewClientUsageMetrics()
		err199 := argvalue1.Read(jsProt198)
		if err199 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetSyncStateWithMetrics(value0, value1))
		fmt.Print("\n")
		break
	case "getSyncChunk":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetSyncChunk requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err201 := (strconv.Atoi(flag.Arg(2)))
		if err201 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err202 := (strconv.Atoi(flag.Arg(3)))
		if err202 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		fmt.Print(client.GetSyncChunk(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getFilteredSyncChunk":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetFilteredSyncChunk requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		tmp1, err205 := (strconv.Atoi(flag.Arg(2)))
		if err205 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err206 := (strconv.Atoi(flag.Arg(3)))
		if err206 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		arg207 := flag.Arg(4)
		mbTrans208 := thrift.NewTMemoryBufferLen(len(arg207))
		defer mbTrans208.Close()
		_, err209 := mbTrans208.WriteString(arg207)
		if err209 != nil {
			Usage()
			return
		}
		factory210 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt211 := factory210.GetProtocol(mbTrans208)
		argvalue3 := notestore.NewSyncChunkFilter()
		err212 := argvalue3.Read(jsProt211)
		if err212 != nil {
			Usage()
			return
		}
		value3 := argvalue3
		fmt.Print(client.GetFilteredSyncChunk(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getLinkedNotebookSyncState":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetLinkedNotebookSyncState requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg214 := flag.Arg(2)
		mbTrans215 := thrift.NewTMemoryBufferLen(len(arg214))
		defer mbTrans215.Close()
		_, err216 := mbTrans215.WriteString(arg214)
		if err216 != nil {
			Usage()
			return
		}
		factory217 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt218 := factory217.GetProtocol(mbTrans215)
		argvalue1 := types.NewLinkedNotebook()
		err219 := argvalue1.Read(jsProt218)
		if err219 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.GetLinkedNotebookSyncState(value0, value1))
		fmt.Print("\n")
		break
	case "getLinkedNotebookSyncChunk":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "GetLinkedNotebookSyncChunk requires 5 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg221 := flag.Arg(2)
		mbTrans222 := thrift.NewTMemoryBufferLen(len(arg221))
		defer mbTrans222.Close()
		_, err223 := mbTrans222.WriteString(arg221)
		if err223 != nil {
			Usage()
			return
		}
		factory224 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt225 := factory224.GetProtocol(mbTrans222)
		argvalue1 := types.NewLinkedNotebook()
		err226 := argvalue1.Read(jsProt225)
		if err226 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err227 := (strconv.Atoi(flag.Arg(3)))
		if err227 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err228 := (strconv.Atoi(flag.Arg(4)))
		if err228 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		fmt.Print(client.GetLinkedNotebookSyncChunk(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "listNotebooks":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ListNotebooks requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ListNotebooks(value0))
		fmt.Print("\n")
		break
	case "getNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "getDefaultNotebook":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetDefaultNotebook requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetDefaultNotebook(value0))
		fmt.Print("\n")
		break
	case "createNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg235 := flag.Arg(2)
		mbTrans236 := thrift.NewTMemoryBufferLen(len(arg235))
		defer mbTrans236.Close()
		_, err237 := mbTrans236.WriteString(arg235)
		if err237 != nil {
			Usage()
			return
		}
		factory238 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt239 := factory238.GetProtocol(mbTrans236)
		argvalue1 := types.NewNotebook()
		err240 := argvalue1.Read(jsProt239)
		if err240 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "updateNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg242 := flag.Arg(2)
		mbTrans243 := thrift.NewTMemoryBufferLen(len(arg242))
		defer mbTrans243.Close()
		_, err244 := mbTrans243.WriteString(arg242)
		if err244 != nil {
			Usage()
			return
		}
		factory245 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt246 := factory245.GetProtocol(mbTrans243)
		argvalue1 := types.NewNotebook()
		err247 := argvalue1.Read(jsProt246)
		if err247 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "expungeNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ExpungeNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "listTags":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ListTags requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ListTags(value0))
		fmt.Print("\n")
		break
	case "listTagsByNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ListTagsByNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ListTagsByNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "getTag":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetTag requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetTag(value0, value1))
		fmt.Print("\n")
		break
	case "createTag":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateTag requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg256 := flag.Arg(2)
		mbTrans257 := thrift.NewTMemoryBufferLen(len(arg256))
		defer mbTrans257.Close()
		_, err258 := mbTrans257.WriteString(arg256)
		if err258 != nil {
			Usage()
			return
		}
		factory259 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt260 := factory259.GetProtocol(mbTrans257)
		argvalue1 := types.NewTag()
		err261 := argvalue1.Read(jsProt260)
		if err261 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateTag(value0, value1))
		fmt.Print("\n")
		break
	case "updateTag":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateTag requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg263 := flag.Arg(2)
		mbTrans264 := thrift.NewTMemoryBufferLen(len(arg263))
		defer mbTrans264.Close()
		_, err265 := mbTrans264.WriteString(arg263)
		if err265 != nil {
			Usage()
			return
		}
		factory266 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt267 := factory266.GetProtocol(mbTrans264)
		argvalue1 := types.NewTag()
		err268 := argvalue1.Read(jsProt267)
		if err268 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateTag(value0, value1))
		fmt.Print("\n")
		break
	case "untagAll":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UntagAll requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.UntagAll(value0, value1))
		fmt.Print("\n")
		break
	case "expungeTag":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeTag requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ExpungeTag(value0, value1))
		fmt.Print("\n")
		break
	case "listSearches":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ListSearches requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ListSearches(value0))
		fmt.Print("\n")
		break
	case "getSearch":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetSearch requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetSearch(value0, value1))
		fmt.Print("\n")
		break
	case "createSearch":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateSearch requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg277 := flag.Arg(2)
		mbTrans278 := thrift.NewTMemoryBufferLen(len(arg277))
		defer mbTrans278.Close()
		_, err279 := mbTrans278.WriteString(arg277)
		if err279 != nil {
			Usage()
			return
		}
		factory280 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt281 := factory280.GetProtocol(mbTrans278)
		argvalue1 := types.NewSavedSearch()
		err282 := argvalue1.Read(jsProt281)
		if err282 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateSearch(value0, value1))
		fmt.Print("\n")
		break
	case "updateSearch":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateSearch requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg284 := flag.Arg(2)
		mbTrans285 := thrift.NewTMemoryBufferLen(len(arg284))
		defer mbTrans285.Close()
		_, err286 := mbTrans285.WriteString(arg284)
		if err286 != nil {
			Usage()
			return
		}
		factory287 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt288 := factory287.GetProtocol(mbTrans285)
		argvalue1 := types.NewSavedSearch()
		err289 := argvalue1.Read(jsProt288)
		if err289 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateSearch(value0, value1))
		fmt.Print("\n")
		break
	case "expungeSearch":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeSearch requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ExpungeSearch(value0, value1))
		fmt.Print("\n")
		break
	case "findNotes":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "FindNotes requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg293 := flag.Arg(2)
		mbTrans294 := thrift.NewTMemoryBufferLen(len(arg293))
		defer mbTrans294.Close()
		_, err295 := mbTrans294.WriteString(arg293)
		if err295 != nil {
			Usage()
			return
		}
		factory296 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt297 := factory296.GetProtocol(mbTrans294)
		argvalue1 := notestore.NewNoteFilter()
		err298 := argvalue1.Read(jsProt297)
		if err298 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err299 := (strconv.Atoi(flag.Arg(3)))
		if err299 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err300 := (strconv.Atoi(flag.Arg(4)))
		if err300 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		fmt.Print(client.FindNotes(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "findNoteOffset":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "FindNoteOffset requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg302 := flag.Arg(2)
		mbTrans303 := thrift.NewTMemoryBufferLen(len(arg302))
		defer mbTrans303.Close()
		_, err304 := mbTrans303.WriteString(arg302)
		if err304 != nil {
			Usage()
			return
		}
		factory305 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt306 := factory305.GetProtocol(mbTrans303)
		argvalue1 := notestore.NewNoteFilter()
		err307 := argvalue1.Read(jsProt306)
		if err307 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := types.GUID(argvalue2)
		fmt.Print(client.FindNoteOffset(value0, value1, value2))
		fmt.Print("\n")
		break
	case "findNotesMetadata":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "FindNotesMetadata requires 5 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg310 := flag.Arg(2)
		mbTrans311 := thrift.NewTMemoryBufferLen(len(arg310))
		defer mbTrans311.Close()
		_, err312 := mbTrans311.WriteString(arg310)
		if err312 != nil {
			Usage()
			return
		}
		factory313 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt314 := factory313.GetProtocol(mbTrans311)
		argvalue1 := notestore.NewNoteFilter()
		err315 := argvalue1.Read(jsProt314)
		if err315 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		tmp2, err316 := (strconv.Atoi(flag.Arg(3)))
		if err316 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err317 := (strconv.Atoi(flag.Arg(4)))
		if err317 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg318 := flag.Arg(5)
		mbTrans319 := thrift.NewTMemoryBufferLen(len(arg318))
		defer mbTrans319.Close()
		_, err320 := mbTrans319.WriteString(arg318)
		if err320 != nil {
			Usage()
			return
		}
		factory321 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt322 := factory321.GetProtocol(mbTrans319)
		argvalue4 := notestore.NewNotesMetadataResultSpec()
		err323 := argvalue4.Read(jsProt322)
		if err323 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.FindNotesMetadata(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "findNoteCounts":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "FindNoteCounts requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg325 := flag.Arg(2)
		mbTrans326 := thrift.NewTMemoryBufferLen(len(arg325))
		defer mbTrans326.Close()
		_, err327 := mbTrans326.WriteString(arg325)
		if err327 != nil {
			Usage()
			return
		}
		factory328 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt329 := factory328.GetProtocol(mbTrans326)
		argvalue1 := notestore.NewNoteFilter()
		err330 := argvalue1.Read(jsProt329)
		if err330 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		fmt.Print(client.FindNoteCounts(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getNote":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetNote requires 6 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		fmt.Print(client.GetNote(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getNoteApplicationData":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetNoteApplicationData requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetNoteApplicationData(value0, value1))
		fmt.Print("\n")
		break
	case "getNoteApplicationDataEntry":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetNoteApplicationDataEntry requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.GetNoteApplicationDataEntry(value0, value1, value2))
		fmt.Print("\n")
		break
	case "setNoteApplicationDataEntry":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SetNoteApplicationDataEntry requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		argvalue3 := flag.Arg(4)
		value3 := argvalue3
		fmt.Print(client.SetNoteApplicationDataEntry(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "unsetNoteApplicationDataEntry":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UnsetNoteApplicationDataEntry requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.UnsetNoteApplicationDataEntry(value0, value1, value2))
		fmt.Print("\n")
		break
	case "getNoteContent":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetNoteContent requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetNoteContent(value0, value1))
		fmt.Print("\n")
		break
	case "getNoteSearchText":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "GetNoteSearchText requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		fmt.Print(client.GetNoteSearchText(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "getResourceSearchText":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceSearchText requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceSearchText(value0, value1))
		fmt.Print("\n")
		break
	case "getNoteTagNames":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetNoteTagNames requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetNoteTagNames(value0, value1))
		fmt.Print("\n")
		break
	case "createNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg361 := flag.Arg(2)
		mbTrans362 := thrift.NewTMemoryBufferLen(len(arg361))
		defer mbTrans362.Close()
		_, err363 := mbTrans362.WriteString(arg361)
		if err363 != nil {
			Usage()
			return
		}
		factory364 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt365 := factory364.GetProtocol(mbTrans362)
		argvalue1 := types.NewNote()
		err366 := argvalue1.Read(jsProt365)
		if err366 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateNote(value0, value1))
		fmt.Print("\n")
		break
	case "updateNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg368 := flag.Arg(2)
		mbTrans369 := thrift.NewTMemoryBufferLen(len(arg368))
		defer mbTrans369.Close()
		_, err370 := mbTrans369.WriteString(arg368)
		if err370 != nil {
			Usage()
			return
		}
		factory371 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt372 := factory371.GetProtocol(mbTrans369)
		argvalue1 := types.NewNote()
		err373 := argvalue1.Read(jsProt372)
		if err373 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateNote(value0, value1))
		fmt.Print("\n")
		break
	case "deleteNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "DeleteNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.DeleteNote(value0, value1))
		fmt.Print("\n")
		break
	case "expungeNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ExpungeNote(value0, value1))
		fmt.Print("\n")
		break
	case "expungeNotes":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeNotes requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg379 := flag.Arg(2)
		mbTrans380 := thrift.NewTMemoryBufferLen(len(arg379))
		defer mbTrans380.Close()
		_, err381 := mbTrans380.WriteString(arg379)
		if err381 != nil {
			Usage()
			return
		}
		factory382 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt383 := factory382.GetProtocol(mbTrans380)
		containerStruct1 := notestore.NewNoteStoreExpungeNotesArgs()
		err384 := containerStruct1.ReadField2(jsProt383)
		if err384 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.NoteGuids
		value1 := argvalue1
		fmt.Print(client.ExpungeNotes(value0, value1))
		fmt.Print("\n")
		break
	case "expungeInactiveNotes":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ExpungeInactiveNotes requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ExpungeInactiveNotes(value0))
		fmt.Print("\n")
		break
	case "copyNote":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "CopyNote requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := types.GUID(argvalue2)
		fmt.Print(client.CopyNote(value0, value1, value2))
		fmt.Print("\n")
		break
	case "listNoteVersions":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ListNoteVersions requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ListNoteVersions(value0, value1))
		fmt.Print("\n")
		break
	case "getNoteVersion":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetNoteVersion requires 6 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		tmp2, err393 := (strconv.Atoi(flag.Arg(3)))
		if err393 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		fmt.Print(client.GetNoteVersion(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getResource":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetResource requires 6 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3) == "true"
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		fmt.Print(client.GetResource(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getResourceApplicationData":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceApplicationData requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceApplicationData(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceApplicationDataEntry":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "GetResourceApplicationDataEntry requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.GetResourceApplicationDataEntry(value0, value1, value2))
		fmt.Print("\n")
		break
	case "setResourceApplicationDataEntry":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SetResourceApplicationDataEntry requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		argvalue3 := flag.Arg(4)
		value3 := argvalue3
		fmt.Print(client.SetResourceApplicationDataEntry(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "unsetResourceApplicationDataEntry":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "UnsetResourceApplicationDataEntry requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.UnsetResourceApplicationDataEntry(value0, value1, value2))
		fmt.Print("\n")
		break
	case "updateResource":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateResource requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg416 := flag.Arg(2)
		mbTrans417 := thrift.NewTMemoryBufferLen(len(arg416))
		defer mbTrans417.Close()
		_, err418 := mbTrans417.WriteString(arg416)
		if err418 != nil {
			Usage()
			return
		}
		factory419 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt420 := factory419.GetProtocol(mbTrans417)
		argvalue1 := types.NewResource()
		err421 := argvalue1.Read(jsProt420)
		if err421 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateResource(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceData":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceData requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceData(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceByHash":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetResourceByHash requires 6 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := []byte(flag.Arg(3))
		value2 := argvalue2
		argvalue3 := flag.Arg(4) == "true"
		value3 := argvalue3
		argvalue4 := flag.Arg(5) == "true"
		value4 := argvalue4
		argvalue5 := flag.Arg(6) == "true"
		value5 := argvalue5
		fmt.Print(client.GetResourceByHash(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getResourceRecognition":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceRecognition requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceRecognition(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceAlternateData":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceAlternateData requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceAlternateData(value0, value1))
		fmt.Print("\n")
		break
	case "getResourceAttributes":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetResourceAttributes requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.GetResourceAttributes(value0, value1))
		fmt.Print("\n")
		break
	case "getPublicNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "GetPublicNotebook requires 2 args")
			flag.Usage()
		}
		tmp0, err436 := (strconv.Atoi(flag.Arg(1)))
		if err436 != nil {
			Usage()
			return
		}
		argvalue0 := int32(tmp0)
		value0 := types.UserID(argvalue0)
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.GetPublicNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "createSharedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateSharedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg439 := flag.Arg(2)
		mbTrans440 := thrift.NewTMemoryBufferLen(len(arg439))
		defer mbTrans440.Close()
		_, err441 := mbTrans440.WriteString(arg439)
		if err441 != nil {
			Usage()
			return
		}
		factory442 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt443 := factory442.GetProtocol(mbTrans440)
		argvalue1 := types.NewSharedNotebook()
		err444 := argvalue1.Read(jsProt443)
		if err444 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateSharedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "updateSharedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateSharedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg446 := flag.Arg(2)
		mbTrans447 := thrift.NewTMemoryBufferLen(len(arg446))
		defer mbTrans447.Close()
		_, err448 := mbTrans447.WriteString(arg446)
		if err448 != nil {
			Usage()
			return
		}
		factory449 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt450 := factory449.GetProtocol(mbTrans447)
		argvalue1 := types.NewSharedNotebook()
		err451 := argvalue1.Read(jsProt450)
		if err451 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateSharedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "setSharedNotebookRecipientSettings":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "SetSharedNotebookRecipientSettings requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1, err453 := (strconv.ParseInt(flag.Arg(2), 10, 64))
		if err453 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg454 := flag.Arg(3)
		mbTrans455 := thrift.NewTMemoryBufferLen(len(arg454))
		defer mbTrans455.Close()
		_, err456 := mbTrans455.WriteString(arg454)
		if err456 != nil {
			Usage()
			return
		}
		factory457 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt458 := factory457.GetProtocol(mbTrans455)
		argvalue2 := types.NewSharedNotebookRecipientSettings()
		err459 := argvalue2.Read(jsProt458)
		if err459 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.SetSharedNotebookRecipientSettings(value0, value1, value2))
		fmt.Print("\n")
		break
	case "sendMessageToSharedNotebookMembers":
		if flag.NArg()-1 != 4 {
			fmt.Fprintln(os.Stderr, "SendMessageToSharedNotebookMembers requires 4 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		arg463 := flag.Arg(4)
		mbTrans464 := thrift.NewTMemoryBufferLen(len(arg463))
		defer mbTrans464.Close()
		_, err465 := mbTrans464.WriteString(arg463)
		if err465 != nil {
			Usage()
			return
		}
		factory466 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt467 := factory466.GetProtocol(mbTrans464)
		containerStruct3 := notestore.NewNoteStoreSendMessageToSharedNotebookMembersArgs()
		err468 := containerStruct3.ReadField4(jsProt467)
		if err468 != nil {
			Usage()
			return
		}
		argvalue3 := containerStruct3.Recipients
		value3 := argvalue3
		fmt.Print(client.SendMessageToSharedNotebookMembers(value0, value1, value2, value3))
		fmt.Print("\n")
		break
	case "listSharedNotebooks":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ListSharedNotebooks requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ListSharedNotebooks(value0))
		fmt.Print("\n")
		break
	case "expungeSharedNotebooks":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeSharedNotebooks requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg471 := flag.Arg(2)
		mbTrans472 := thrift.NewTMemoryBufferLen(len(arg471))
		defer mbTrans472.Close()
		_, err473 := mbTrans472.WriteString(arg471)
		if err473 != nil {
			Usage()
			return
		}
		factory474 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt475 := factory474.GetProtocol(mbTrans472)
		containerStruct1 := notestore.NewNoteStoreExpungeSharedNotebooksArgs()
		err476 := containerStruct1.ReadField2(jsProt475)
		if err476 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.SharedNotebookIds
		value1 := argvalue1
		fmt.Print(client.ExpungeSharedNotebooks(value0, value1))
		fmt.Print("\n")
		break
	case "createLinkedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "CreateLinkedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg478 := flag.Arg(2)
		mbTrans479 := thrift.NewTMemoryBufferLen(len(arg478))
		defer mbTrans479.Close()
		_, err480 := mbTrans479.WriteString(arg478)
		if err480 != nil {
			Usage()
			return
		}
		factory481 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt482 := factory481.GetProtocol(mbTrans479)
		argvalue1 := types.NewLinkedNotebook()
		err483 := argvalue1.Read(jsProt482)
		if err483 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.CreateLinkedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "updateLinkedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "UpdateLinkedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg485 := flag.Arg(2)
		mbTrans486 := thrift.NewTMemoryBufferLen(len(arg485))
		defer mbTrans486.Close()
		_, err487 := mbTrans486.WriteString(arg485)
		if err487 != nil {
			Usage()
			return
		}
		factory488 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt489 := factory488.GetProtocol(mbTrans486)
		argvalue1 := types.NewLinkedNotebook()
		err490 := argvalue1.Read(jsProt489)
		if err490 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.UpdateLinkedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "listLinkedNotebooks":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "ListLinkedNotebooks requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.ListLinkedNotebooks(value0))
		fmt.Print("\n")
		break
	case "expungeLinkedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ExpungeLinkedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ExpungeLinkedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "authenticateToSharedNotebook":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "AuthenticateToSharedNotebook requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		fmt.Print(client.AuthenticateToSharedNotebook(value0, value1))
		fmt.Print("\n")
		break
	case "getSharedNotebookByAuth":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "GetSharedNotebookByAuth requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.GetSharedNotebookByAuth(value0))
		fmt.Print("\n")
		break
	case "emailNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "EmailNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg498 := flag.Arg(2)
		mbTrans499 := thrift.NewTMemoryBufferLen(len(arg498))
		defer mbTrans499.Close()
		_, err500 := mbTrans499.WriteString(arg498)
		if err500 != nil {
			Usage()
			return
		}
		factory501 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt502 := factory501.GetProtocol(mbTrans499)
		argvalue1 := notestore.NewNoteEmailParameters()
		err503 := argvalue1.Read(jsProt502)
		if err503 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		fmt.Print(client.EmailNote(value0, value1))
		fmt.Print("\n")
		break
	case "shareNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "ShareNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.ShareNote(value0, value1))
		fmt.Print("\n")
		break
	case "stopSharingNote":
		if flag.NArg()-1 != 2 {
			fmt.Fprintln(os.Stderr, "StopSharingNote requires 2 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := types.GUID(argvalue1)
		fmt.Print(client.StopSharingNote(value0, value1))
		fmt.Print("\n")
		break
	case "authenticateToSharedNote":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "AuthenticateToSharedNote requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		argvalue1 := flag.Arg(2)
		value1 := argvalue1
		argvalue2 := flag.Arg(3)
		value2 := argvalue2
		fmt.Print(client.AuthenticateToSharedNote(value0, value1, value2))
		fmt.Print("\n")
		break
	case "findRelated":
		if flag.NArg()-1 != 3 {
			fmt.Fprintln(os.Stderr, "FindRelated requires 3 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		arg512 := flag.Arg(2)
		mbTrans513 := thrift.NewTMemoryBufferLen(len(arg512))
		defer mbTrans513.Close()
		_, err514 := mbTrans513.WriteString(arg512)
		if err514 != nil {
			Usage()
			return
		}
		factory515 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt516 := factory515.GetProtocol(mbTrans513)
		argvalue1 := notestore.NewRelatedQuery()
		err517 := argvalue1.Read(jsProt516)
		if err517 != nil {
			Usage()
			return
		}
		value1 := argvalue1
		arg518 := flag.Arg(3)
		mbTrans519 := thrift.NewTMemoryBufferLen(len(arg518))
		defer mbTrans519.Close()
		_, err520 := mbTrans519.WriteString(arg518)
		if err520 != nil {
			Usage()
			return
		}
		factory521 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt522 := factory521.GetProtocol(mbTrans519)
		argvalue2 := notestore.NewRelatedResultSpec()
		err523 := argvalue2.Read(jsProt522)
		if err523 != nil {
			Usage()
			return
		}
		value2 := argvalue2
		fmt.Print(client.FindRelated(value0, value1, value2))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #29
0
ファイル: user_svc-remote.go プロジェクト: mdennebaum/pelican
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := user.NewUserSvcClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "create":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Create requires 1 args")
			flag.Usage()
		}
		arg15 := flag.Arg(1)
		mbTrans16 := thrift.NewTMemoryBufferLen(len(arg15))
		defer mbTrans16.Close()
		_, err17 := mbTrans16.WriteString(arg15)
		if err17 != nil {
			Usage()
			return
		}
		factory18 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt19 := factory18.GetProtocol(mbTrans16)
		argvalue0 := user.NewUser()
		err20 := argvalue0.Read(jsProt19)
		if err20 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.Create(value0))
		fmt.Print("\n")
		break
	case "read":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Read requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.Read(value0))
		fmt.Print("\n")
		break
	case "update":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Update requires 1 args")
			flag.Usage()
		}
		arg22 := flag.Arg(1)
		mbTrans23 := thrift.NewTMemoryBufferLen(len(arg22))
		defer mbTrans23.Close()
		_, err24 := mbTrans23.WriteString(arg22)
		if err24 != nil {
			Usage()
			return
		}
		factory25 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt26 := factory25.GetProtocol(mbTrans23)
		argvalue0 := user.NewUser()
		err27 := argvalue0.Read(jsProt26)
		if err27 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		fmt.Print(client.Update(value0))
		fmt.Print("\n")
		break
	case "destroy":
		if flag.NArg()-1 != 1 {
			fmt.Fprintln(os.Stderr, "Destroy requires 1 args")
			flag.Usage()
		}
		argvalue0 := flag.Arg(1)
		value0 := argvalue0
		fmt.Print(client.Destroy(value0))
		fmt.Print("\n")
		break
	case "fetch":
		if flag.NArg()-1 != 0 {
			fmt.Fprintln(os.Stderr, "Fetch requires 0 args")
			flag.Usage()
		}
		fmt.Print(client.Fetch())
		fmt.Print("\n")
		break
	case "reset":
		if flag.NArg()-1 != 0 {
			fmt.Fprintln(os.Stderr, "Reset requires 0 args")
			flag.Usage()
		}
		fmt.Print(client.Reset())
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}
コード例 #30
0
func main() {
	flag.Usage = Usage
	var host string
	var port int
	var protocol string
	var urlString string
	var framed bool
	var useHttp bool
	var parsedUrl url.URL
	var trans thrift.TTransport
	_ = strconv.Atoi
	_ = math.Abs
	flag.Usage = Usage
	flag.StringVar(&host, "h", "localhost", "Specify host and port")
	flag.IntVar(&port, "p", 9090, "Specify port")
	flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
	flag.StringVar(&urlString, "u", "", "Specify the url")
	flag.BoolVar(&framed, "framed", false, "Use framed transport")
	flag.BoolVar(&useHttp, "http", false, "Use http")
	flag.Parse()

	if len(urlString) > 0 {
		parsedUrl, err := url.Parse(urlString)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
		host = parsedUrl.Host
		useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
	} else if useHttp {
		_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
			flag.Usage()
		}
	}

	cmd := flag.Arg(0)
	var err error
	if useHttp {
		trans, err = thrift.NewTHttpClient(parsedUrl.String())
	} else {
		portStr := fmt.Sprint(port)
		if strings.Contains(host, ":") {
			host, portStr, err = net.SplitHostPort(host)
			if err != nil {
				fmt.Fprintln(os.Stderr, "error with host:", err)
				os.Exit(1)
			}
		}
		trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
		if err != nil {
			fmt.Fprintln(os.Stderr, "error resolving address:", err)
			os.Exit(1)
		}
		if framed {
			trans = thrift.NewTFramedTransport(trans)
		}
	}
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating transport", err)
		os.Exit(1)
	}
	defer trans.Close()
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
		break
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
		break
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
		break
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
		Usage()
		os.Exit(1)
	}
	client := services.NewRecommendationManagerClientFactory(trans, protocolFactory)
	if err := trans.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
		os.Exit(1)
	}

	switch cmd {
	case "getResourceRecommendation":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetResourceRecommendation requires 7 args")
			flag.Usage()
		}
		argvalue0, err1405 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1405 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err := (strconv.Atoi(flag.Arg(2)))
		if err != nil {
			Usage()
			return
		}
		argvalue1 := services.ResourceType(tmp1)
		value1 := argvalue1
		tmp2, err1406 := (strconv.Atoi(flag.Arg(3)))
		if err1406 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1407 := (strconv.Atoi(flag.Arg(4)))
		if err1407 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		arg1408 := flag.Arg(5)
		mbTrans1409 := thrift.NewTMemoryBufferLen(len(arg1408))
		defer mbTrans1409.Close()
		_, err1410 := mbTrans1409.WriteString(arg1408)
		if err1410 != nil {
			Usage()
			return
		}
		factory1411 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1412 := factory1411.GetProtocol(mbTrans1409)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1413 := argvalue4.Read(jsProt1412)
		if err1413 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		tmp5, err := (strconv.Atoi(flag.Arg(6)))
		if err != nil {
			Usage()
			return
		}
		argvalue5 := services.RecommendationReason(tmp5)
		value5 := argvalue5
		arg1414 := flag.Arg(7)
		mbTrans1415 := thrift.NewTMemoryBufferLen(len(arg1414))
		defer mbTrans1415.Close()
		_, err1416 := mbTrans1415.WriteString(arg1414)
		if err1416 != nil {
			Usage()
			return
		}
		factory1417 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1418 := factory1417.GetProtocol(mbTrans1415)
		argvalue6 := services.NewFromInfo()
		err1419 := argvalue6.Read(jsProt1418)
		if err1419 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetResourceRecommendation(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getGroupRecommendation":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetGroupRecommendation requires 6 args")
			flag.Usage()
		}
		argvalue0, err1420 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1420 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1421 := (strconv.Atoi(flag.Arg(2)))
		if err1421 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1422 := (strconv.Atoi(flag.Arg(3)))
		if err1422 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1423 := flag.Arg(5)
		mbTrans1424 := thrift.NewTMemoryBufferLen(len(arg1423))
		defer mbTrans1424.Close()
		_, err1425 := mbTrans1424.WriteString(arg1423)
		if err1425 != nil {
			Usage()
			return
		}
		factory1426 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1427 := factory1426.GetProtocol(mbTrans1424)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1428 := argvalue4.Read(jsProt1427)
		if err1428 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg1429 := flag.Arg(6)
		mbTrans1430 := thrift.NewTMemoryBufferLen(len(arg1429))
		defer mbTrans1430.Close()
		_, err1431 := mbTrans1430.WriteString(arg1429)
		if err1431 != nil {
			Usage()
			return
		}
		factory1432 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1433 := factory1432.GetProtocol(mbTrans1430)
		argvalue5 := services.NewFromInfo()
		err1434 := argvalue5.Read(jsProt1433)
		if err1434 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetGroupRecommendation(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "getTagRecommendation":
		if flag.NArg()-1 != 7 {
			fmt.Fprintln(os.Stderr, "GetTagRecommendation requires 7 args")
			flag.Usage()
		}
		argvalue0, err1435 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1435 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		arg1436 := flag.Arg(2)
		mbTrans1437 := thrift.NewTMemoryBufferLen(len(arg1436))
		defer mbTrans1437.Close()
		_, err1438 := mbTrans1437.WriteString(arg1436)
		if err1438 != nil {
			Usage()
			return
		}
		factory1439 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1440 := factory1439.GetProtocol(mbTrans1437)
		containerStruct1 := services.NewGetTagRecommendationArgs()
		err1441 := containerStruct1.ReadField2(jsProt1440)
		if err1441 != nil {
			Usage()
			return
		}
		argvalue1 := containerStruct1.TagList
		value1 := argvalue1
		tmp2, err1442 := (strconv.Atoi(flag.Arg(3)))
		if err1442 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err1443 := (strconv.Atoi(flag.Arg(4)))
		if err1443 != nil {
			Usage()
			return
		}
		argvalue3 := int32(tmp3)
		value3 := argvalue3
		tmp4, err := (strconv.Atoi(flag.Arg(5)))
		if err != nil {
			Usage()
			return
		}
		argvalue4 := services.RecommendationReason(tmp4)
		value4 := argvalue4
		tmp5, err := (strconv.Atoi(flag.Arg(6)))
		if err != nil {
			Usage()
			return
		}
		argvalue5 := services.ResourceType(tmp5)
		value5 := argvalue5
		arg1444 := flag.Arg(7)
		mbTrans1445 := thrift.NewTMemoryBufferLen(len(arg1444))
		defer mbTrans1445.Close()
		_, err1446 := mbTrans1445.WriteString(arg1444)
		if err1446 != nil {
			Usage()
			return
		}
		factory1447 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1448 := factory1447.GetProtocol(mbTrans1445)
		argvalue6 := services.NewFromInfo()
		err1449 := argvalue6.Read(jsProt1448)
		if err1449 != nil {
			Usage()
			return
		}
		value6 := argvalue6
		fmt.Print(client.GetTagRecommendation(value0, value1, value2, value3, value4, value5, value6))
		fmt.Print("\n")
		break
	case "getFriendRecommendation":
		if flag.NArg()-1 != 5 {
			fmt.Fprintln(os.Stderr, "GetFriendRecommendation requires 5 args")
			flag.Usage()
		}
		argvalue0, err1450 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1450 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1451 := (strconv.Atoi(flag.Arg(2)))
		if err1451 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1452 := (strconv.Atoi(flag.Arg(3)))
		if err1452 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1453 := flag.Arg(5)
		mbTrans1454 := thrift.NewTMemoryBufferLen(len(arg1453))
		defer mbTrans1454.Close()
		_, err1455 := mbTrans1454.WriteString(arg1453)
		if err1455 != nil {
			Usage()
			return
		}
		factory1456 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1457 := factory1456.GetProtocol(mbTrans1454)
		argvalue4 := services.NewFromInfo()
		err1458 := argvalue4.Read(jsProt1457)
		if err1458 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		fmt.Print(client.GetFriendRecommendation(value0, value1, value2, value3, value4))
		fmt.Print("\n")
		break
	case "getRecommendationByMix":
		if flag.NArg()-1 != 6 {
			fmt.Fprintln(os.Stderr, "GetRecommendationByMix requires 6 args")
			flag.Usage()
		}
		argvalue0, err1459 := (strconv.ParseInt(flag.Arg(1), 10, 64))
		if err1459 != nil {
			Usage()
			return
		}
		value0 := argvalue0
		tmp1, err1460 := (strconv.Atoi(flag.Arg(2)))
		if err1460 != nil {
			Usage()
			return
		}
		argvalue1 := int32(tmp1)
		value1 := argvalue1
		tmp2, err1461 := (strconv.Atoi(flag.Arg(3)))
		if err1461 != nil {
			Usage()
			return
		}
		argvalue2 := int32(tmp2)
		value2 := argvalue2
		tmp3, err := (strconv.Atoi(flag.Arg(4)))
		if err != nil {
			Usage()
			return
		}
		argvalue3 := services.RecommendationReason(tmp3)
		value3 := argvalue3
		arg1462 := flag.Arg(5)
		mbTrans1463 := thrift.NewTMemoryBufferLen(len(arg1462))
		defer mbTrans1463.Close()
		_, err1464 := mbTrans1463.WriteString(arg1462)
		if err1464 != nil {
			Usage()
			return
		}
		factory1465 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1466 := factory1465.GetProtocol(mbTrans1463)
		argvalue4 := services.NewRecommendationAugmentInfo()
		err1467 := argvalue4.Read(jsProt1466)
		if err1467 != nil {
			Usage()
			return
		}
		value4 := argvalue4
		arg1468 := flag.Arg(6)
		mbTrans1469 := thrift.NewTMemoryBufferLen(len(arg1468))
		defer mbTrans1469.Close()
		_, err1470 := mbTrans1469.WriteString(arg1468)
		if err1470 != nil {
			Usage()
			return
		}
		factory1471 := thrift.NewTSimpleJSONProtocolFactory()
		jsProt1472 := factory1471.GetProtocol(mbTrans1469)
		argvalue5 := services.NewFromInfo()
		err1473 := argvalue5.Read(jsProt1472)
		if err1473 != nil {
			Usage()
			return
		}
		value5 := argvalue5
		fmt.Print(client.GetRecommendationByMix(value0, value1, value2, value3, value4, value5))
		fmt.Print("\n")
		break
	case "":
		Usage()
		break
	default:
		fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
	}
}