Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow migration of static api to work for connectors, allow exposing … #318

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (

// Pitaya App interface
type Pitaya interface {
AddAcceptor(acceptor.Acceptor)
GetDieChan() chan bool
SetDebug(debug bool)
SetHeartbeatTime(interval time.Duration)
Expand Down Expand Up @@ -208,6 +209,15 @@ func NewApp(
return app
}

// AddAcceptor adds a new acceptor to app
func (app *App) AddAcceptor(ac acceptor.Acceptor) {
if !app.server.Frontend {
logger.Log.Error("tried to add an acceptor to a backend server, skipping")
return
}
app.acceptors = append(app.acceptors, ac)
}

// GetDieChan gets the channel that the app sinalizes when its going to die
func (app *App) GetDieChan() chan bool {
return app.dieChan
Expand Down
14 changes: 14 additions & 0 deletions mocks/app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions static.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/spf13/viper"
"github.com/topfreegames/pitaya/v2/acceptor"
"github.com/topfreegames/pitaya/v2/cluster"
"github.com/topfreegames/pitaya/v2/component"
"github.com/topfreegames/pitaya/v2/config"
Expand Down Expand Up @@ -220,3 +221,7 @@ func RegisterModuleBefore(module interfaces.Module, name string) error {
func GetModule(name string) (interfaces.Module, error) {
return DefaultApp.GetModule(name)
}

func AddAcceptor(ac acceptor.Acceptor) {
DefaultApp.AddAcceptor(ac)
}
Loading