Upgrading dependencies to gorealis v2 and thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-12-26 17:25:59 -08:00
parent 7cbbea498b
commit 54b8d7942a
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1327 changed files with 137391 additions and 61476 deletions

View file

@ -17,30 +17,28 @@
# under the License.
#
THRIFT = $(top_builddir)/compiler/cpp/thrift
gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tutorial/tutorial.thrift
$(THRIFT) --gen go -r $<
$(THRIFT) --gen go$(COMPILER_EXTRAFLAG) -r $<
all-local: gen-go/tutorial/calculator.go
check: src/git.apache.org/thrift.git/lib/go/thrift
$(THRIFT) -r --gen go $(top_srcdir)/tutorial/tutorial.thrift
check: src/github.com/apache/thrift/lib/go/thrift thirdparty-dep
$(THRIFT) -r --gen go$(COMPILER_EXTRAFLAG) $(top_srcdir)/tutorial/tutorial.thrift
cp -r gen-go/* src/
GOPATH=`pwd` $(GO) build ./...
GOPATH=`pwd` $(GO) build -o go-tutorial src/*.go
GOPATH=`pwd` $(GO) build -o go-tutorial ./src
GOPATH=`pwd` $(GO) build -o calculator-remote src/tutorial/calculator-remote/calculator-remote.go
src/git.apache.org/thrift.git/lib/go/thrift:
mkdir -p src/git.apache.org/thrift.git/lib/go
ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/git.apache.org/thrift.git/lib/go/thrift
src/github.com/apache/thrift/lib/go/thrift:
mkdir -p src/github.com/apache/thrift/lib/go
ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/github.com/apache/thrift/lib/go/thrift
thirdparty-dep:
tutorialserver: all
GOPATH=`pwd` $(GO) run src/*.go -server=true
tutorialclient: all
GOPATH=`pwd` $(GO) run src/*.go
GOPATH=`pwd` $(GO) run src/*.go
tutorialsecureserver: all
GOPATH=`pwd` $(GO) run src/*.go -server=true -secure=true

View file

@ -20,24 +20,28 @@ package main
*/
import (
"context"
"crypto/tls"
"fmt"
"git.apache.org/thrift.git/lib/go/thrift"
"tutorial"
"github.com/apache/thrift/lib/go/thrift"
)
var defaultCtx = context.Background()
func handleClient(client *tutorial.CalculatorClient) (err error) {
client.Ping()
client.Ping(defaultCtx)
fmt.Println("ping()")
sum, _ := client.Add(1, 1)
sum, _ := client.Add(defaultCtx, 1, 1)
fmt.Print("1+1=", sum, "\n")
work := tutorial.NewWork()
work.Op = tutorial.Operation_DIVIDE
work.Num1 = 1
work.Num2 = 0
quotient, err := client.Calculate(1, work)
quotient, err := client.Calculate(defaultCtx, 1, work)
if err != nil {
switch v := err.(type) {
case *tutorial.InvalidOperation:
@ -53,7 +57,7 @@ func handleClient(client *tutorial.CalculatorClient) (err error) {
work.Op = tutorial.Operation_SUBTRACT
work.Num1 = 15
work.Num2 = 10
diff, err := client.Calculate(1, work)
diff, err := client.Calculate(defaultCtx, 1, work)
if err != nil {
switch v := err.(type) {
case *tutorial.InvalidOperation:
@ -66,7 +70,7 @@ func handleClient(client *tutorial.CalculatorClient) (err error) {
fmt.Print("15-10=", diff, "\n")
}
log, err := client.GetStruct(1)
log, err := client.GetStruct(defaultCtx, 1)
if err != nil {
fmt.Println("Unable to get struct:", err)
return err
@ -98,5 +102,7 @@ func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift
if err := transport.Open(); err != nil {
return err
}
return handleClient(tutorial.NewCalculatorClientFactory(transport, protocolFactory))
iprot := protocolFactory.GetProtocol(transport)
oprot := protocolFactory.GetProtocol(transport)
return handleClient(tutorial.NewCalculatorClient(thrift.NewTStandardClient(iprot, oprot)))
}

View file

@ -20,6 +20,7 @@ package main
*/
import (
"context"
"fmt"
"shared"
"strconv"
@ -34,17 +35,17 @@ func NewCalculatorHandler() *CalculatorHandler {
return &CalculatorHandler{log: make(map[int]*shared.SharedStruct)}
}
func (p *CalculatorHandler) Ping() (err error) {
func (p *CalculatorHandler) Ping(ctx context.Context) (err error) {
fmt.Print("ping()\n")
return nil
}
func (p *CalculatorHandler) Add(num1 int32, num2 int32) (retval17 int32, err error) {
func (p *CalculatorHandler) Add(ctx context.Context, num1 int32, num2 int32) (retval17 int32, err error) {
fmt.Print("add(", num1, ",", num2, ")\n")
return num1 + num2, nil
}
func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, err error) {
func (p *CalculatorHandler) Calculate(ctx context.Context, logid int32, w *tutorial.Work) (val int32, err error) {
fmt.Print("calculate(", logid, ", {", w.Op, ",", w.Num1, ",", w.Num2, "})\n")
switch w.Op {
case tutorial.Operation_ADD:
@ -89,13 +90,13 @@ func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32,
return val, err
}
func (p *CalculatorHandler) GetStruct(key int32) (*shared.SharedStruct, error) {
func (p *CalculatorHandler) GetStruct(ctx context.Context, key int32) (*shared.SharedStruct, error) {
fmt.Print("getStruct(", key, ")\n")
v, _ := p.log[int(key)]
return v, nil
}
func (p *CalculatorHandler) Zip() (err error) {
func (p *CalculatorHandler) Zip(ctx context.Context) (err error) {
fmt.Print("zip()\n")
return nil
}

View file

@ -22,7 +22,7 @@ package main
import (
"flag"
"fmt"
"git.apache.org/thrift.git/lib/go/thrift"
"github.com/apache/thrift/lib/go/thrift"
"os"
)

View file

@ -22,7 +22,7 @@ package main
import (
"crypto/tls"
"fmt"
"git.apache.org/thrift.git/lib/go/thrift"
"github.com/apache/thrift/lib/go/thrift"
"tutorial"
)