Skip to content

Commit

Permalink
docs: update server/v2 api contract (#22815)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Dec 11, 2024
1 parent 0adf6fd commit c08ab17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion runtime/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ProvideModuleConfigMaps(
fetchFlag := flag
// splitting on "." is required to handle nested flags which are defined
// in other modules that are not the current module
// for example: "server.minimum-gas-prices" is defined in the server module
// for example: "server.minimum-gas-prices" is defined in the server component
// but required by x/validate
for _, part := range strings.Split(flag, ".") {
if maybeMap, ok := m[part]; ok {
Expand Down
22 changes: 13 additions & 9 deletions server/v2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,49 @@ import (
"cosmossdk.io/log"
)

// ServerComponent is a server module that can be started and stopped.
// ServerComponent is a server component that can be started and stopped.
type ServerComponent[T transaction.Tx] interface {
// Name returns the name of the server component.
Name() string

// Start starts the server component.
Start(context.Context) error
// Stop stops the server component.
// Once Stop has been called on a server component, it may not be reused.
Stop(context.Context) error
}

// HasStartFlags is a server module that has start flags.
// HasStartFlags is a server component that has start flags.
type HasStartFlags interface {
// StartCmdFlags returns server start flags.
// Those flags should be prefixed with the server name.
// They are then merged with the server config in one viper instance.
StartCmdFlags() *pflag.FlagSet
}

// HasConfig is a server module that has a config.
// HasConfig is a server component that has a config.
type HasConfig interface {
Config() any
}

// ConfigWriter is a server module that can write its config to a file.
// ConfigWriter is a server component that can write its config to a file.
type ConfigWriter interface {
WriteConfig(path string) error
}

// HasCLICommands is a server module that has CLI commands.
// HasCLICommands is a server component that has CLI commands.
type HasCLICommands interface {
CLICommands() CLIConfig
}

// CLIConfig defines the CLI configuration for a module server.
// CLIConfig defines the CLI configuration for a component server.
type CLIConfig struct {
// Commands defines the main command of a module server.
// Commands defines the main command of a server component.
Commands []*cobra.Command
// Queries defines the query commands of a module server.
// Queries defines the query commands of a server component.
// Those commands are meant to be added in the root query command.
Queries []*cobra.Command
// Txs defines the tx commands of a module server.
// Txs defines the tx commands of a server component.
// Those commands are meant to be added in the root tx command.
Txs []*cobra.Command
}
Expand Down

0 comments on commit c08ab17

Please sign in to comment.