Пример #1
0
func Update(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, variable *person.Person) (*person.Person, error) {
	socket, err := thrift.NewTSocket("localhost:4000")
	if err != nil {
		log.Println(err)
	}
	transport := transportFactory.GetTransport(socket)
	client := person.NewPersonServiceClientFactory(transport, protocolFactory)
	defer client.Transport.Close()

	if err := client.Transport.Open(); err != nil {
		log.Println(err)
	}

	result, err := client.Update(variable)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, nil
}
Пример #2
0
func Delete(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, id int64) error {
	socket, err := thrift.NewTSocket("localhost:4000")
	if err != nil {
		log.Println(err)
	}
	transport := transportFactory.GetTransport(socket)
	client := person.NewPersonServiceClientFactory(transport, protocolFactory)
	defer client.Transport.Close()

	if err := client.Transport.Open(); err != nil {
		log.Println(err)
	}

	err = client.Destroy(id)
	if err != nil {
		log.Println(err)
		return err
	}
	return nil
}