mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
revert: debug
This commit is contained in:
parent
07c3475cc9
commit
164ebf3a66
21
Makefile
21
Makefile
@ -1,30 +1,34 @@
|
||||
.DEFAULT_GOAL:=help
|
||||
|
||||
.PHONY: check
|
||||
## Run lint & test
|
||||
check: tidy examples lint test
|
||||
|
||||
.PHONY: test
|
||||
## Run go test
|
||||
test:
|
||||
go test -v ./...
|
||||
@go test -v ./...
|
||||
|
||||
.PHONY: install
|
||||
## Run go install
|
||||
install:
|
||||
go install cmd/gotsrpc/gotsrpc.go
|
||||
@go install cmd/gotsrpc/gotsrpc.go
|
||||
|
||||
.PHONY: install.debug
|
||||
## Run go install with debug
|
||||
install.debug:
|
||||
go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go
|
||||
@go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go
|
||||
|
||||
.PHONY: outdated
|
||||
## Show outdated direct dependencies
|
||||
outdated:
|
||||
go list -u -m -json all | go-mod-outdated -update -direct
|
||||
@go list -u -m -json all | go-mod-outdated -update -direct
|
||||
|
||||
.PHONY: build.debug
|
||||
## Build binary in debug mode
|
||||
build.debug:
|
||||
rm -f bin/gotsrpc
|
||||
go build -gcflags "all=-N -l" -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
|
||||
@rm -f bin/gotsrpc
|
||||
@go build -gcflags "all=-N -l" -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
|
||||
|
||||
## === Tools ===
|
||||
|
||||
@ -49,17 +53,18 @@ example.$(1).lint:
|
||||
endef
|
||||
$(foreach p,$(EXAMPLES),$(eval $(call examples,$(p))))
|
||||
|
||||
## Run go mod tidy recursive
|
||||
.PHONY: lint
|
||||
## Run linter
|
||||
lint:
|
||||
@golangci-lint run
|
||||
|
||||
.PHONY: lint.fix
|
||||
## Run linter and fix
|
||||
lint.fix:
|
||||
@golangci-lint run --fix
|
||||
|
||||
.PHONY: tidy
|
||||
## Run go mod tidy recursive
|
||||
## Run go mod tidy
|
||||
tidy:
|
||||
@go mod tidy
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package frontend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/foomo/gotsrpc/v2/example/errors/service/backend"
|
||||
"github.com/foomo/gotsrpc/v2/example/errors/service/frontend"
|
||||
@ -20,12 +18,6 @@ func New(client backend.ServiceGoTSRPCClient) *Handler {
|
||||
}
|
||||
|
||||
func (h *Handler) Simple(w http.ResponseWriter, r *http.Request) (e *frontend.ErrSimple) {
|
||||
fmt.Println("==========> incoming")
|
||||
time.Sleep(time.Second)
|
||||
if r.Context().Err() != nil {
|
||||
fmt.Println("==========>" + r.Context().Err().Error())
|
||||
}
|
||||
fmt.Println("<========== outgoing")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -39,7 +40,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second)
|
||||
// _ = exec.Command("open", "http://127.0.0.1:3000").Run()
|
||||
_ = exec.Command("open", "http://127.0.0.1:3000").Run()
|
||||
call()
|
||||
}()
|
||||
|
||||
@ -48,30 +49,12 @@ func main() {
|
||||
|
||||
func call() {
|
||||
ctx := context.Background()
|
||||
time.Sleep(time.Second)
|
||||
|
||||
ctx2, cancel := context.WithCancel(ctx)
|
||||
req, _ := http.NewRequestWithContext(ctx2, "POST", "http://127.0.0.1:3000/service/frontend/Simple", nil)
|
||||
go func() {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
fmt.Println("cancel")
|
||||
cancel()
|
||||
}()
|
||||
fmt.Println("sending request")
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
time.Sleep(time.Second)
|
||||
fmt.Printf("%v\n", err)
|
||||
fmt.Printf("%v\n", res.StatusCode)
|
||||
|
||||
c := backendsvs.NewDefaultServiceGoTSRPCClient("http://localhost:3000")
|
||||
|
||||
{
|
||||
fmt.Println("--- Error ----------------------")
|
||||
var gotsrpcErr *gotsrpc.Error
|
||||
|
||||
ctx2, cancel2 := context.WithCancel(ctx)
|
||||
cancel2()
|
||||
serviceErr, err := c.Error(ctx2)
|
||||
serviceErr, err := c.Error(ctx)
|
||||
if err != nil {
|
||||
panic("client error should be nil")
|
||||
} else if serviceErr == nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user