Skip to content

Commit

Permalink
Refactor project preparing for v3 new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
felipejfc committed Jul 29, 2024
1 parent 19a7f40 commit 781bd5f
Show file tree
Hide file tree
Showing 281 changed files with 910 additions and 1,672 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ TESTABLE_PACKAGES = `go list ./... | $(GREP_CMD) examples | $(GREP_CMD) constant
setup: init-submodules
@go get ./...

build-cli:
build:
@$(MKFOLDER)
@go build -o build/$(BIN) github.com/topfreegames/pitaya/v2/pitaya-cli
@go build -o build/$(BIN) .
@echo "build pitaya-cli at ./build/$(BIN)"

build-k6-extension:
@$(MKFOLDER)
@xk6 build --with github.com/topfreegames/xk6-pitaya=./xk6-pitaya/ --with github.com/topfreegames/pitaya/v2=./ --with google.golang.org/grpc=google.golang.org/[email protected] --output ./build/$(XK6_BIN)
@xk6 build --with github.com/topfreegames/xk6-pitaya=./xk6-pitaya/ --with github.com/topfreegames/pitaya/v3=./ --with google.golang.org/grpc=google.golang.org/[email protected] --output ./build/$(XK6_BIN)
@echo "build pitaya k6 extension at ./build/$(XK6_BIN)"

init-submodules:
Expand Down Expand Up @@ -179,23 +179,23 @@ test-coverage-func coverage-func: test-coverage merge-profiles
mocks: agent-mock session-mock networkentity-mock pitaya-mock serializer-mock metrics-mock acceptor-mock

agent-mock:
@mockgen github.com/topfreegames/pitaya/v2/agent Agent,AgentFactory | sed 's/mock_agent/mocks/' > agent/mocks/agent.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/agent Agent,AgentFactory | sed 's/mock_agent/mocks/' > pkg/agent/mocks/agent.go

session-mock:
@mockgen github.com/topfreegames/pitaya/v2/session Session,SessionPool | sed 's/mock_session/mocks/' > session/mocks/session.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/session Session,SessionPool | sed 's/mock_session/mocks/' > pkg/session/mocks/session.go

networkentity-mock:
@mockgen github.com/topfreegames/pitaya/v2/networkentity NetworkEntity | sed 's/mock_networkentity/mocks/' > networkentity/mocks/networkentity.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/networkentity NetworkEntity | sed 's/mock_networkentity/mocks/' > pkg/networkentity/mocks/networkentity.go

pitaya-mock:
@mockgen github.com/topfreegames/pitaya/v2 Pitaya | sed 's/mock_v2/mocks/' > mocks/app.go
@mockgen github.com/topfreegames/pitaya/v3/pkg Pitaya | sed 's/mock_v2/mocks/' > pkg/mocks/app.go

metrics-mock:
@mockgen github.com/topfreegames/pitaya/v2/metrics Reporter | sed 's/mock_metrics/mocks/' > metrics/mocks/reporter.go
@mockgen github.com/topfreegames/pitaya/v2/metrics Client | sed 's/mock_metrics/mocks/' > metrics/mocks/statsd_reporter.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/metrics Reporter | sed 's/mock_metrics/mocks/' > pkg/metrics/mocks/reporter.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/metrics Client | sed 's/mock_metrics/mocks/' > pkg/metrics/mocks/statsd_reporter.go

serializer-mock:
@mockgen github.com/topfreegames/pitaya/v2/serialize Serializer | sed 's/mock_serialize/mocks/' > serialize/mocks/serializer.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/serialize Serializer | sed 's/mock_serialize/mocks/' > pkg/serialize/mocks/serializer.go

acceptor-mock:
@mockgen github.com/topfreegames/pitaya/v2/acceptor PlayerConn,Acceptor | sed 's/mock_acceptor/mocks/' > mocks/acceptor.go
@mockgen github.com/topfreegames/pitaya/v3/pkg/acceptor PlayerConn,Acceptor | sed 's/mock_acceptor/mocks/' > pkg/mocks/acceptor.go
2 changes: 1 addition & 1 deletion benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"

"github.com/sirupsen/logrus"
"github.com/topfreegames/pitaya/v2/client"
"github.com/topfreegames/pitaya/v3/pkg/client"
)

var clients []*client.Client
Expand Down
42 changes: 42 additions & 0 deletions cmd/repl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright � 2021 Wildlife Studios
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"github.com/spf13/cobra"
"github.com/topfreegames/pitaya/v3/repl"
)

var docsRoute string
var fileName string
var prettyJSON bool

// replCmd opens pitaya REPL tool
var replCmd = &cobra.Command{
Use: "repl",
Short: "starts pitaya repl tool",
Long: `starts pitaya repl tool`,
Run: func(cmd *cobra.Command, args []string) {
repl.Start(docsRoute, fileName, prettyJSON)
},
}

func init() {
replCmd.Flags().StringVarP(&docsRoute, "docs", "d", "", "route containing the documentation")
replCmd.Flags().StringVarP(&fileName, "filename", "f", "", "file containing the commands to run")
replCmd.Flags().BoolVarP(&prettyJSON, "pretty", "p", false, "print pretty jsons")
rootCmd.AddCommand(replCmd)
}
41 changes: 41 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2024 Wildlife Studios
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"github.com/spf13/cobra"
)

var cfgFile string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "pitaya",
Short: "run pitaya cmd",
Long: `run pitaya cmd`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cobra.CheckErr(rootCmd.Execute())
}

func init() {
}
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A REPL cli client made in go for pitaya.
## Installing

```
go install github.com/topfreegames/pitaya/v2/pitaya-cli
go install github.com/topfreegames/pitaya/v3/pitaya-cli
```

## Usage
Expand Down
6 changes: 3 additions & 3 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/google/uuid"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/topfreegames/pitaya/v2/client"
"github.com/topfreegames/pitaya/v2/conn/message"
"github.com/topfreegames/pitaya/v2/helpers"
"github.com/topfreegames/pitaya/v3/pkg/client"
"github.com/topfreegames/pitaya/v3/pkg/conn/message"
"github.com/topfreegames/pitaya/v3/pkg/helpers"
)

var update = flag.Bool("update", false, "update server binary")
Expand Down
14 changes: 7 additions & 7 deletions examples/demo/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

"strings"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/groups"
"github.com/topfreegames/pitaya/v2/logger"
"github.com/topfreegames/pitaya/v2/timer"
"github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
"github.com/topfreegames/pitaya/v3/pkg/groups"
"github.com/topfreegames/pitaya/v3/pkg/logger"
"github.com/topfreegames/pitaya/v3/pkg/timer"
)

type (
Expand Down
18 changes: 9 additions & 9 deletions examples/demo/cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (

"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/cluster"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/examples/demo/cluster/services"
"github.com/topfreegames/pitaya/v2/groups"
"github.com/topfreegames/pitaya/v2/route"
"github.com/topfreegames/pitaya/v2/tracing"
"github.com/topfreegames/pitaya/v3/examples/demo/cluster/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/cluster"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
"github.com/topfreegames/pitaya/v3/pkg/groups"
"github.com/topfreegames/pitaya/v3/pkg/route"
"github.com/topfreegames/pitaya/v3/pkg/tracing"
)

var app pitaya.Pitaya
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/cluster/services/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/json"
"fmt"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/examples/demo/protos"
pitayaprotos "github.com/topfreegames/pitaya/v2/protos"
"github.com/topfreegames/pitaya/v3/examples/demo/protos"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/component"
pitayaprotos "github.com/topfreegames/pitaya/v3/pkg/protos"
)

// ConnectorRemote is a remote that will receive rpc's
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/cluster/services/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"time"

"github.com/google/uuid"
"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/examples/demo/protos"
"github.com/topfreegames/pitaya/v2/timer"
"github.com/topfreegames/pitaya/v3/examples/demo/protos"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/timer"
)

type (
Expand Down
20 changes: 10 additions & 10 deletions examples/demo/cluster_grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (

"strings"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/cluster"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/constants"
"github.com/topfreegames/pitaya/v2/examples/demo/cluster_grpc/services"
"github.com/topfreegames/pitaya/v2/groups"
"github.com/topfreegames/pitaya/v2/modules"
"github.com/topfreegames/pitaya/v2/route"
"github.com/topfreegames/pitaya/v3/examples/demo/cluster_grpc/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/cluster"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
"github.com/topfreegames/pitaya/v3/pkg/constants"
"github.com/topfreegames/pitaya/v3/pkg/groups"
"github.com/topfreegames/pitaya/v3/pkg/modules"
"github.com/topfreegames/pitaya/v3/pkg/route"
)

var app pitaya.Pitaya
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/cluster_grpc/services/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/examples/demo/protos"
"github.com/topfreegames/pitaya/v3/examples/demo/protos"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/component"
)

// ConnectorRemote is a remote that will receive rpc's
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/cluster_grpc/services/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strconv"
"time"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/examples/demo/protos"
"github.com/topfreegames/pitaya/v2/timer"
"github.com/topfreegames/pitaya/v3/examples/demo/protos"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/timer"
)

type (
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/custom_metrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"strings"

"github.com/spf13/viper"
"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/examples/demo/custom_metrics/services"
"github.com/topfreegames/pitaya/v3/examples/demo/custom_metrics/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
)

var app pitaya.Pitaya
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/custom_metrics/services/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package services
import (
"context"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/examples/demo/custom_metrics/messages"
"github.com/topfreegames/pitaya/v3/examples/demo/custom_metrics/messages"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/component"
)

// Room server
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/pipeline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"flag"
"fmt"

"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
)

// MetagameServer ...
Expand Down
14 changes: 7 additions & 7 deletions examples/demo/rate_limiting/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"time"

"github.com/spf13/viper"
"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/acceptorwrapper"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/examples/demo/rate_limiting/services"
"github.com/topfreegames/pitaya/v2/metrics"
"github.com/topfreegames/pitaya/v3/examples/demo/rate_limiting/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/acceptorwrapper"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
"github.com/topfreegames/pitaya/v3/pkg/metrics"
)

func createAcceptor(port int, reporters []metrics.Reporter) acceptor.Acceptor {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/rate_limiting/services/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package services
import (
"context"

"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v3/pkg/component"
)

// Room represents a component that contains a bundle of room related handler
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"strings"

"github.com/spf13/viper"
"github.com/topfreegames/pitaya/v2"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/examples/demo/worker/services"
"github.com/topfreegames/pitaya/v3/examples/demo/worker/services"
pitaya "github.com/topfreegames/pitaya/v3/pkg"
"github.com/topfreegames/pitaya/v3/pkg/acceptor"
"github.com/topfreegames/pitaya/v3/pkg/component"
"github.com/topfreegames/pitaya/v3/pkg/config"
)

var app pitaya.Pitaya
Expand Down
Loading

0 comments on commit 781bd5f

Please sign in to comment.