-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦 new: use configbuilder to parse config files into
Config
struct (#25
) * new: configbuilder.ConfigJSON * fix: unused wasmClone * new: configbuilder.ConfigProtoBuf Plus, make configbuilder no longer an internal package. * feat: UnmarshalJSON and UnmarshalProto for Config * deprecated: use of Argv and Env inside WATM Deprecate the use of `argv` and `env` inside a WATM. A WATM is encouraged to be configured with `Config.TransportModuleConfig`. To prevent the unnecessary warning this may introduce to some undocumented legitimate use, we will not add `Deprecated` flag on the related fields and functions. Signed-off-by: Gaukas Wang <[email protected]> --------- Signed-off-by: Gaukas Wang <[email protected]>
- Loading branch information
Showing
9 changed files
with
743 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package configbuilder | ||
|
||
// ConfigJSON defines the JSON format of the Config. | ||
// | ||
// This struct may fail to fully represent the Config struct, as it is | ||
// non-trivial to represent a func or other non-serialized structures. | ||
type ConfigJSON struct { | ||
TransportModule struct { | ||
BinPath string `json:"bin"` // Path to the transport module binary | ||
ConfigPath string `json:"config,omitempty"` // Path to the transport module config file | ||
} `json:"transport_module"` | ||
|
||
Network struct { | ||
// DialerFunc string `json:"dialer_func,omitempty"` // we have no good way to represent a func in JSON format yet | ||
Listener struct { | ||
Network string `json:"network"` // e.g. "tcp" | ||
Address string `json:"address"` // e.g. "0.0.0.0:0" | ||
} `json:"listener,omitempty"` | ||
} `json:"network,omitempty"` | ||
|
||
Module struct { | ||
Argv []string `json:"argv,omitempty"` // Warning: this isn't a recommended way to pass configuration to the WebAssembly module. Instead, use TransportModuleConfig for a serializable configuration file. | ||
Env map[string]string `json:"env,omitempty"` // Warning: this isn't a recommended way to pass configuration to the WebAssembly module. Instead, use TransportModuleConfig for a serializable configuration file. | ||
InheritStdin bool `json:"inherit_stdin,omitempty"` | ||
InheritStdout bool `json:"inherit_stdout,omitempty"` | ||
InheritStderr bool `json:"inherit_stderr,omitempty"` | ||
PreopenedDirs map[string]string `json:"preopened_dirs,omitempty"` // hostPath: guestPath | ||
} `json:"module,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package configbuilder | ||
|
||
import "github.com/gaukas/water/configbuilder/pb" | ||
|
||
// ConfigProtoBuf defines the Protobuf format of the Config. | ||
// | ||
// This struct may fail to fully represent the Config struct, as it is | ||
// non-trivial to represent a func or other non-serialized structures. | ||
type ConfigProtoBuf = pb.Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
protobuf: config.proto | ||
protoc --go_out=. --go_opt=paths=source_relative $< | ||
|
||
.PHONY: protobuf |
Oops, something went wrong.