Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f0e9732
feat: basic sketch for QUICAcceptor
Oct 7, 2024
c7c961c
refactor: add TODO for HTTP/3 integration while awaiting testing
Oct 7, 2024
b6ebaf3
refactor: add TODO for HTTP/3 integration while awaiting testing
Oct 7, 2024
996c7c9
refactor: update QUIC acceptor to use quic-go, add connection wrapper…
Oct 8, 2024
952f655
feat: Refactor QUIC acceptor
Oct 8, 2024
3093d37
feat: Refactor QUIC acceptor
Oct 8, 2024
52b3d8c
fix: increase context timeout in Accept method to prevent deadline ex…
Oct 8, 2024
5fe9bc7
refact: TLS config
Oct 9, 2024
51a72c1
refactor: adjust time
Oct 10, 2024
046174c
feat: adding a server that uses NewQuicAcceptor but does not follow t…
Oct 14, 2024
f83a633
feat: created connectToQUIC logic
Oct 14, 2024
98a3e19
feat: receiving and sending encoded messages
Oct 15, 2024
5af9cdb
refactor: message pattern
Oct 15, 2024
d7cdb0e
feat: adding heartbeat to keep connection alive
Oct 15, 2024
5ecf6c3
Merge branch 'feature/quic-server' of https://github.com/juniorjse/pi…
Oct 15, 2024
025e85c
feat: making client work for cluster_grpc server
Oct 16, 2024
4f0a099
feat: making connectToQuic in pitaya-cli
Oct 17, 2024
f0bfa2f
feat: changing xk6-pitaya client to connect via QUIC
Oct 28, 2024
85d044c
refactor: housecleaning - deleting files that were not being used any…
Nov 7, 2024
c6b21b0
refactor: removing forgotten debug logs
Nov 7, 2024
79d5738
refactor: remove main_quic and simplify to a single main
Nov 11, 2024
3d2a7dc
refactor: Make QuicConnWrapper timeout configurable with default of 1…
Nov 11, 2024
8364172
refactor: enhance QUIC stream message handling with header parsing, t…
Nov 11, 2024
8ac55ef
refactor: fix xk6 build and modified scenarios for quic server
Nov 21, 2024
817eb41
feat: Add flag to select TCP or QUIC as acceptor
Nov 21, 2024
7d6b914
fix: fixing requests timeouts
Nov 21, 2024
7b6b5f7
feat: adding ALPN h3 to both client and server
Feb 14, 2025
552fcd1
feat: adding .der certificate file
Feb 26, 2025
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
41 changes: 36 additions & 5 deletions examples/demo/cluster_grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"strconv"

"strings"
"time"

"github.com/quic-go/quic-go"
"github.com/topfreegames/pitaya/v3/examples/demo/cluster_grpc/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
Expand Down Expand Up @@ -80,6 +82,7 @@ func main() {
svType := flag.String("type", "connector", "the server type")
isFrontend := flag.Bool("frontend", true, "if server is frontend")
rpcServerPort := flag.Int("rpcsvport", 3434, "the port that grpc server will listen")
acceptorType := flag.String("acceptor", "tcp", "the type of acceptor to use (tcp or quic)")

flag.Parse()

Expand All @@ -89,7 +92,7 @@ func main() {
}

var bs *modules.ETCDBindingStorage
app, bs = createApp(*port, *isFrontend, *svType, meta, *rpcServerPort)
app, bs = createApp(*port, *isFrontend, *svType, meta, *rpcServerPort, *acceptorType)

defer app.Shutdown()

Expand All @@ -102,7 +105,7 @@ func main() {
app.Start()
}

func createApp(port int, isFrontend bool, svType string, meta map[string]string, rpcServerPort int) (pitaya.Pitaya, *modules.ETCDBindingStorage) {
func createApp(port int, isFrontend bool, svType string, meta map[string]string, rpcServerPort int, acceptorType string) (pitaya.Pitaya, *modules.ETCDBindingStorage) {
builder := pitaya.NewDefaultBuilder(isFrontend, svType, pitaya.Cluster, meta, *config.NewDefaultPitayaConfig())

grpcServerConfig := builder.Config.Cluster.RPC.Server.Grpc
Expand All @@ -129,9 +132,37 @@ func createApp(port int, isFrontend bool, svType string, meta map[string]string,
builder.RPCClient = gc

if isFrontend {
tcp := acceptor.NewTCPAcceptor(fmt.Sprintf(":%d", port))
builder.AddAcceptor(tcp)
switch acceptorType {
case "quic":
tlsConf := &tls.Config{
Certificates: []tls.Certificate{
loadTLSCertificates(),
},
NextProtos: []string{"h3"},
}
quicConf := &quic.Config{
MaxIdleTimeout: 35 * time.Second,
EnableDatagrams: true,
}
quicAcceptor := acceptor.NewQuicAcceptor(fmt.Sprintf(":%d", port), tlsConf, quicConf)
builder.AddAcceptor(quicAcceptor)
case "tcp":
tcp := acceptor.NewTCPAcceptor(fmt.Sprintf(":%d", port))
builder.AddAcceptor(tcp)
default:
panic(fmt.Sprintf("Invalid acceptor type: %s. Use 'tcp' or 'quic'.", acceptorType))
}
}

return builder.Build(), bs
}

func loadTLSCertificates() tls.Certificate {
certPath := "../../../pkg/acceptor/fixtures/server.crt"
keyPath := "../../../pkg/acceptor/fixtures/server.key"
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
panic(fmt.Sprintf("Erro ao carregar certificados TLS: %v", err))
}
return cert
}
40 changes: 20 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ toolchain go1.22.4

require (
github.com/DataDog/datadog-go v4.8.3+incompatible
github.com/abiosoft/ishell/v2 v2.0.2
github.com/go-playground/validator/v10 v10.13.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.0
github.com/jhump/protoreflect v1.15.1
github.com/mailgun/proxyproto v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/nats-io/nats-server/v2 v2.10.18
github.com/nats-io/nats.go v1.36.0
github.com/nats-io/nuid v1.0.1
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/client_golang v1.19.1
github.com/quic-go/quic-go v0.47.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.9.0
github.com/topfreegames/go-workers v1.2.1
Expand All @@ -31,14 +35,15 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
golang.org/x/net v0.27.0
golang.org/x/net v0.28.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.2
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/abiosoft/ishell/v2 v2.0.2 // indirect
github.com/abiosoft/ishell v2.0.0+incompatible // indirect
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -48,7 +53,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.13.0 // indirect
Expand All @@ -58,11 +62,13 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/gomodule/redigo v1.9.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
Expand All @@ -72,36 +78,29 @@ require (
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/ksubedi/gomove v0.0.0-20200106182546-e1fa47256217 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/minio/highwayhash v1.0.3 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nats-io/jwt/v2 v2.5.8 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.43.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/urfave/cli v1.22.15 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.etcd.io/etcd/client/v2 v2.305.11 // indirect
Expand All @@ -112,14 +111,15 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
Expand Down
Loading