From fc08275244713e90ebec8980e455535bbc68cfbf Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 10 Dec 2024 15:22:01 +0100 Subject: [PATCH 1/2] docs: update server/v2 api contract --- runtime/v2/config.go | 4 ++-- server/v2/server.go | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/runtime/v2/config.go b/runtime/v2/config.go index 4cddadd7be20..b4909f691412 100644 --- a/runtime/v2/config.go +++ b/runtime/v2/config.go @@ -34,8 +34,8 @@ func ProvideModuleConfigMaps( m := globalConfig 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 + // in other modules that are not the current component + // 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 { diff --git a/server/v2/server.go b/server/v2/server.go index 5dd8a73d76ad..9f4f3ee66e58 100644 --- a/server/v2/server.go +++ b/server/v2/server.go @@ -16,15 +16,19 @@ 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. @@ -32,29 +36,29 @@ type HasStartFlags interface { 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 } From 5b6719a4c6cdef8bcc473803ec9b9a1259870157 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 10 Dec 2024 15:23:23 +0100 Subject: [PATCH 2/2] diff --- runtime/v2/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/v2/config.go b/runtime/v2/config.go index b4909f691412..aec6a992abfb 100644 --- a/runtime/v2/config.go +++ b/runtime/v2/config.go @@ -34,7 +34,7 @@ func ProvideModuleConfigMaps( m := globalConfig fetchFlag := flag // splitting on "." is required to handle nested flags which are defined - // in other modules that are not the current component + // in other modules that are not the current module // for example: "server.minimum-gas-prices" is defined in the server component // but required by x/validate for _, part := range strings.Split(flag, ".") {