Skip to content

Commit

Permalink
ping rpc config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Dec 28, 2024
1 parent 0787351 commit a35ae94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions internal/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func Run(cmd *cobra.Command, configFile string) {
if err != nil {
log.Fatal().Err(err).Msg("error setting up client handler")
}
if cfg.RPC.Ping {
log.Info().Str("method", cfg.RPC.PingMethod).Msg("RPC ping extension enabled")
clientHandler.SetRPCExtension(cfg.RPC.PingMethod, func(c client.Client, e centrifuge.RPCEvent) (centrifuge.RPCReply, error) {
if cfg.RPC.Ping.Enabled {
log.Info().Str("method", cfg.RPC.Ping.Method).Msg("RPC ping extension enabled")
clientHandler.SetRPCExtension(cfg.RPC.Ping.Method, func(c client.Client, e centrifuge.RPCEvent) (centrifuge.RPCReply, error) {
return centrifuge.RPCReply{}, nil
})
}
Expand Down
10 changes: 7 additions & 3 deletions internal/configtypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,14 @@ type RPC struct {
WithoutNamespace RpcOptions `mapstructure:"without_namespace" json:"without_namespace" envconfig:"without_namespace" yaml:"without_namespace" toml:"without_namespace"`
// RPCNamespaces is a list of rpc namespaces. Each rpc namespace can have its own set of rules.
Namespaces RPCNamespaces `mapstructure:"namespaces" default:"[]" json:"namespaces" envconfig:"namespaces" yaml:"namespaces" toml:"namespaces"`
// Ping is a configuration for RPC ping method.
Ping RPCPing `mapstructure:"ping" json:"ping" envconfig:"ping" yaml:"ping" toml:"ping"`
NamespaceBoundary string `mapstructure:"namespace_boundary" json:"namespace_boundary" envconfig:"namespace_boundary" default:":" yaml:"namespace_boundary" toml:"namespace_boundary"`
}

Ping bool `mapstructure:"ping" json:"ping" envconfig:"ping" yaml:"ping" toml:"ping"`
PingMethod string `mapstructure:"ping_method" json:"ping_method" envconfig:"ping_method" default:"ping" yaml:"ping_method" toml:"ping_method"`
NamespaceBoundary string `mapstructure:"namespace_boundary" json:"namespace_boundary" envconfig:"namespace_boundary" default:":" yaml:"namespace_boundary" toml:"namespace_boundary"`
type RPCPing struct {
Enabled bool `mapstructure:"enabled" json:"enabled" envconfig:"enabled" yaml:"enabled" toml:"enabled"`
Method string `mapstructure:"method" json:"method" envconfig:"method" default:"ping" yaml:"method" toml:"method"`
}

type NamedProxy struct {
Expand Down

0 comments on commit a35ae94

Please sign in to comment.