Skip to content
Open

a #491

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
dc45a18
BeforeHandler return context
codingcn Dec 14, 2020
9943b0b
fix BeforeHandler.Handlers res
Dec 15, 2020
2b1b9ff
fix TestBeforeHandler test
Dec 16, 2020
d2bb5f0
Migrate from Travis CI to Github Actions (#159)
victor-carvalho Jan 6, 2021
053dc61
Update go version
victor-carvalho Jan 7, 2021
d062a17
Update dependencies (#161)
victor-carvalho Jan 13, 2021
3ac8d06
Update several libraries and dependencies
rsafonseca Mar 20, 2021
d9ceab8
fix make setup, broken since 1.1.5
rsafonseca Mar 20, 2021
f16dfdd
Prevent gigantic flood of error messages when etcd channel dies
rsafonseca Mar 21, 2021
370d7ce
update test libs
rsafonseca Mar 21, 2021
d28ae61
update more libs
rsafonseca Mar 21, 2021
3328b0e
Add 2 tests to statsd metrics
rsafonseca Mar 21, 2021
6662b35
Fix session test after nats-2.0 server upgrade in helpers
rsafonseca Mar 22, 2021
ae67201
fix cluster tests
rsafonseca Mar 22, 2021
506edba
fix service test
rsafonseca Mar 22, 2021
371658f
Fix remaining tests
rsafonseca Mar 22, 2021
fd9cf18
Remove accidental file addition
rsafonseca Mar 22, 2021
a0958fc
Fix error assertion
rsafonseca Mar 22, 2021
bb02946
Merge pull request #170 from topfreegames/update_deps
rsafonseca Mar 22, 2021
a94883f
Fix error check in test
rsafonseca Mar 23, 2021
8251063
Recover service discovery from etcd client channels closing
rsafonseca Mar 23, 2021
930e1d4
Revert "Fix tests (#154)"
rsafonseca Mar 24, 2021
41329c3
Revert to returning original error object
rsafonseca Mar 24, 2021
22e4a99
Don't try to initialize real client during test
rsafonseca Mar 24, 2021
85893ce
Add RPC type info to spans
rsafonseca Mar 24, 2021
e487b30
Don't log nats URL on reconnect since it contains credentials when us…
rsafonseca Mar 24, 2021
dbfae28
Drain NATS server connections instead of closing directly
rsafonseca Mar 24, 2021
177cdf3
Merge pull request #172 from topfreegames/fixbugs
rsafonseca Mar 24, 2021
60c9f16
Use single get on syncservers and parallelise parsing only
rsafonseca Apr 26, 2021
540d51f
Run gofmt on changed files
rsafonseca Apr 26, 2021
150c31e
Only get full payload on server initialization
rsafonseca Apr 26, 2021
5ae9a55
Add logging for syncservers time, change syncservers timing on flaky …
rsafonseca Apr 26, 2021
761010f
Log error if etcd get fails
rsafonseca Apr 26, 2021
d5a0dc1
Merge pull request #184 from topfreegames/fix_syncservers
rsafonseca Apr 26, 2021
e68a52d
Only advertise server once initial sync is finished
rsafonseca Apr 26, 2021
f586cd4
Watched should initialise before running SyncServers() to avoid misse…
rsafonseca Apr 29, 2021
83c3926
Watcher should avoid conflicts with syncservers()
rsafonseca Apr 29, 2021
4db9750
ETCD de-registration should wait longer by default. If any server is …
rsafonseca Apr 29, 2021
549aeb3
Check for syncservers() finish more often
rsafonseca Apr 29, 2021
8bad863
Only try brute reinitialization of client after 10 consecutive watch …
rsafonseca Apr 29, 2021
878ccea
move syncServersRunning into struct and use defer to flip its value. …
rsafonseca Apr 29, 2021
617e836
fix accidental timing change
rsafonseca Apr 29, 2021
a0bee66
Use channels for communication between syncservers() and watchetcdcha…
rsafonseca Apr 30, 2021
c61f379
Merge pull request #188 from topfreegames/fix_initialisation
rsafonseca Apr 30, 2021
8ee67b8
Merge pull request #1 from topfreegames/master
zengjiwen May 3, 2021
861c275
[bug fix] add remote component init
zengjiwen May 4, 2021
cb574db
[optimize] redundant assign
zengjiwen May 4, 2021
42c0f58
handle error with InitETCDClient()
hakulala May 7, 2021
389a640
agent has its own remoteAddr(), should not directly call the conn's
hakulala May 8, 2021
4f6a221
handle error for tls.Listen, avoid that listener may be nil, which wi…
hakulala May 12, 2021
37c9d24
Revert "agent has its own remoteAddr(), should not directly call the …
hakulala May 12, 2021
f6182c1
[bug fix] add remote component init
zengjiwen May 4, 2021
a6b7a56
[optimize] redundant assign
zengjiwen May 4, 2021
ec24c92
conn/message: add mutex to routes/codes maps
rochacon Apr 20, 2021
f909ce5
conn/message: protect routes map exposure on GetDictionary
rochacon Apr 27, 2021
d881ee3
agent has its own remoteAddr(), should not directly call the conn's
hakulala May 8, 2021
972abba
Revert "agent has its own remoteAddr(), should not directly call the …
hakulala May 12, 2021
136a930
replace uuid with nuid for requestID in processMessage()
hakulala May 19, 2021
c2f832a
add github.com/nats-io/nuid
chgz May 19, 2021
28b7fb5
Update README.md with github actions badge
felipejfc May 21, 2021
38e2a1b
agent has its own remoteAddr(), should not directly call the conn's
hakulala May 8, 2021
32e70f6
Revert "agent has its own remoteAddr(), should not directly call the …
hakulala May 12, 2021
fac48bf
when processing RPC requests, do not create new requests and response…
hakulala May 21, 2021
54d2ae3
handle error with GetContextFromRequest(), response should be init
hakulala May 21, 2021
57ebd50
Merge branch 'topfreegames:master' into master
zengjiwen Jun 8, 2021
783183d
[optimize] reduce response objects creation
hakulala Jun 11, 2021
3b3a670
[optimize] the return of Call() must be copied
hakulala Jun 11, 2021
1c2db6f
fix(client): fix when routes have no return (output)
gabrielcorado Jul 28, 2021
bad14ac
chore(makefile): add a target to compile examples protos
gabrielcorado Jul 28, 2021
ce8c93a
chore(examples): update cluster example to use only protobuf
gabrielcorado Jul 28, 2021
565ab50
Merge pull request #225 from topfreegames/bugfix/clientproto
gabrielcorado Jul 29, 2021
ad970f0
[bug fix]return err when parse failed
zengjiwen Aug 1, 2021
10789d3
Merge branch 'topfreegames:master' into master
zengjiwen Aug 1, 2021
6fb530e
Merge remote-tracking branch 'origin/master'
zengjiwen Aug 1, 2021
ebfd662
Merge pull request #226 from zengjiwen/master
henriqueoelze Aug 3, 2021
11ffeff
some logic optimiztaion (#210)
chgz Aug 3, 2021
efb6836
refactor(cluster): change initial size of get servers return map
gabrielcorado Aug 6, 2021
56a7cf9
Merge pull request #230 from topfreegames/feature/change-initial-size…
gabrielcorado Aug 6, 2021
f70bec2
Updating dependencies (#237)
henriqueoelze Aug 19, 2021
54e457b
Adding deprecation warning at README.md file
Aug 19, 2021
07f2cd1
Merge pull request #241 from topfreegames/feature/add-deprecation-war…
luizmiranda7 Aug 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
deps:
name: Dependencies
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.15'
- name: Checkout
uses: actions/checkout@v2
- name: Restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
unit-test:
name: Unit Test
runs-on: ubuntu-latest
needs: deps
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.13'
- name: Checkout
uses: actions/checkout@v2
- name: Restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup dependencies
env:
GO111MODULE: off
run: make setup-ci
- name: Run tests
run: make test-coverage
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ~/go/bin/goveralls -coverprofile=coverprofile.out -service=github
e2e-test-nats:
name: Nats Test End to End
runs-on: ubuntu-latest
needs: deps
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.13'
- name: Checkout
uses: actions/checkout@v2
- name: Restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: make e2e-test-nats
e2e-test-grpc:
name: GRPC Test End to End
runs-on: ubuntu-latest
needs: deps
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.13'
- name: Checkout
uses: actions/checkout@v2
- name: Restore cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: make e2e-test-grpc
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ run-custom-metrics-example:
run-rate-limiting-example:
@go run examples/demo/rate_limiting/main.go

protos-compile-demo:
@protoc -I examples/demo/protos examples/demo/protos/*.proto --go_out=.

protos-compile:
@cd benchmark/testdata && ./gen_proto.sh
@protoc -I pitaya-protos/ pitaya-protos/*.proto --go_out=plugins=grpc:protos
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# pitaya [![Build Status][7]][8] [![Coverage Status][9]][10] [![GoDoc][1]][2] [![Docs][11]][12] [![Go Report Card][3]][4] [![MIT licensed][5]][6]

*WARNING*: This version has entered the deprecation flow described [here](https://github.com/topfreegames/pitaya/issues/240), we strongly recommend to use the new version of Pitaya v2.x found in the [main branch](https://github.com/topfreegames/pitaya/tree/main).

---

[1]: https://godoc.org/github.com/topfreegames/pitaya?status.svg
[2]: https://godoc.org/github.com/topfreegames/pitaya
[3]: https://goreportcard.com/badge/github.com/topfreegames/pitaya
[4]: https://goreportcard.com/report/github.com/topfreegames/pitaya
[5]: https://img.shields.io/badge/license-MIT-blue.svg
[6]: LICENSE
[7]: https://travis-ci.org/topfreegames/pitaya.svg?branch=master
[8]: https://travis-ci.org/topfreegames/pitaya
[7]: https://github.com/topfreegames/pitaya/actions/workflows/tests.yaml/badge.svg
[8]: https://github.com/topfreegames/pitaya/actions/workflows/tests.yaml
[9]: https://coveralls.io/repos/github/topfreegames/pitaya/badge.svg?branch=master
[10]: https://coveralls.io/github/topfreegames/pitaya?branch=master
[11]: https://readthedocs.org/projects/pitaya/badge/?version=latest
Expand Down Expand Up @@ -41,7 +45,7 @@ Here's one example of running Pitaya:

Start etcd (This command requires docker-compose and will run an etcd container locally. An etcd may be run without docker if prefered.)
```
cd ./examples/testing && docker-compose up -d etcd
docker-compose -f examples/testing/docker-compose.yml up -d etcd
```
run the connector frontend server from cluster_grpc example
```
Expand Down
3 changes: 3 additions & 0 deletions acceptor/tcp_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func (a *TCPAcceptor) ListenAndServeTLS(cert, key string) {
tlsCfg := &tls.Config{Certificates: []tls.Certificate{crt}}

listener, err := tls.Listen("tcp", a.addr, tlsCfg)
if err != nil {
logger.Log.Fatalf("Failed to listen: %s", err.Error())
}
a.listener = listener
a.running = true
a.serve()
Expand Down
2 changes: 1 addition & 1 deletion app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"testing"
"time"

"github.com/coreos/etcd/integration"
"go.etcd.io/etcd/integration"
"github.com/google/uuid"
opentracing "github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"
Expand Down
31 changes: 18 additions & 13 deletions client/protoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"strings"
"time"
Expand Down Expand Up @@ -144,6 +145,11 @@ func getOutputInputNames(command map[string]interface{}) (string, string, error)

out := command["output"]
outputDocsArr := out.([]interface{})
// we can have handlers that have no return specified.
if len(outputDocsArr) == 0 {
return inputName, "", nil
}

outputDocs, ok := outputDocsArr[0].(map[string]interface{})
if ok {
for k := range outputDocs {
Expand Down Expand Up @@ -211,7 +217,7 @@ func (pc *ProtoClient) getDescriptors(data string) error {
cmdInfo := v.(map[string]interface{})
in, out, err := getOutputInputNames(cmdInfo)
if err != nil {
return err
return fmt.Errorf("failed to get output and input names for '%s' handler: %w", k, err)
}

var command Command
Expand Down Expand Up @@ -250,33 +256,33 @@ func (pc *ProtoClient) getDescriptors(data string) error {

encodedNames, err := proto.Marshal(protname)
if err != nil {
return err
return fmt.Errorf("failed to encode proto names: %w", err)
}
_, err = pc.SendRequest(pc.descriptorsRoute, encodedNames)
if err != nil {
return err
return fmt.Errorf("failed to send proto descriptors request: %w", err)
}

response := <-pc.Client.IncomingMsgChan
descriptors := &protos.ProtoDescriptors{}
if err := proto.Unmarshal(response.Data, descriptors); err != nil {
return err
return fmt.Errorf("failed to unmarshal proto descriptors response: %w", err)
}

// get all proto types
descriptorArray := make([]*protobuf.FileDescriptorProto, 0)
for i := range descriptors.Desc {
fileDescriptorProto, err := unpackDescriptor(descriptors.Desc[i])
if err != nil {
return err
return fmt.Errorf("failed to unpack descriptor: %w", err)
}

descriptorArray = append(descriptorArray, fileDescriptorProto)
pc.descriptorsNames[names[i]] = true
}

if err = pc.buildProtosFromDescriptor(descriptorArray); err != nil {
return err
return fmt.Errorf("failed to build proto from descriptor: %w", err)
}

return nil
Expand Down Expand Up @@ -341,11 +347,11 @@ func (pc *ProtoClient) LoadServerInfo(addr string) error {

docs := &protos.Doc{}
if err := proto.Unmarshal(response.Data, docs); err != nil {
return err
return fmt.Errorf("failed to unmarshal docs route response: %w", err)
}

if err := pc.getDescriptors(docs.Doc); err != nil {
return err
return fmt.Errorf("failed to read proto descriptors: %w", err)
}

pc.Disconnect()
Expand All @@ -369,7 +375,6 @@ func (pc *ProtoClient) waitForData() {
for {
select {
case response := <-pc.Client.IncomingMsgChan:

inputMsg := dynamic.NewMessage(pc.expectedInputDescriptor)

msg, ok := pc.info.Commands[response.Route]
Expand All @@ -388,27 +393,27 @@ func (pc *ProtoClient) waitForData() {
}
response.Data, err = json.Marshal(errMsg)
if err != nil {
logger.Log.Errorf("Erro encode error to json: %s", string(response.Data))
logger.Log.Errorf("error encode error to json: %s", string(response.Data))
continue
}
pc.IncomingMsgChan <- response
continue
}

if inputMsg == nil {
logger.Log.Errorf("Not expected data: %s", string(response.Data))
logger.Log.Errorf("not expected data: %s", string(response.Data))
continue
}

err := inputMsg.Unmarshal(response.Data)
if err != nil {
logger.Log.Errorf("Erro decode data: %s", string(response.Data))
logger.Log.Errorf("error decode data: %s", string(response.Data))
continue
}

data, err2 := inputMsg.MarshalJSON()
if err2 != nil {
logger.Log.Errorf("Erro encode data to json: %s", string(response.Data))
logger.Log.Errorf("error encode data to json: %s", string(response.Data))
continue
}

Expand Down
Loading