Documentation ¶
Index ¶
- Variables
- func Execute()
- func LoadConfig(path string, logger slog.Logger) (sconf *conf.SlingConfig, err error)
- func NewSendEmul(sendArgs *emul.SendArgs) (em *emul.Emul, err error)
- func PrintObj(obj interface{}, w io.Writer) error
- type BoolVal
- type Commander
- type EventID
- type Flag
- func (f Flag) AddEvent(name interface{}, performing interface{}, parameters ...interface{}) (flag bool, err error)
- func (f Flag) Changed() (bool, error)
- func (f *Flag) EqualDefault(val interface{}) bool
- func (f *Flag) EqualVal(val interface{}) bool
- func (f Flag) FireEvent(event interface{}, parameters ...interface{}) (err error)
- func (f Flag) SetValue(val interface{})
- type FlagID
- type FlagType
- type Flagmapper
- type Flags
- func (fs Flags) Add(flag *Flag, persist bool)
- func (fs Flags) AddEvent(flagID FlagID, name interface{}, performing interface{}, ...) (flag bool, err error)
- func (fs Flags) GetExplicit() map[FlagID]*Flag
- func (fs Flags) GetFlagmap() map[FlagID]*Flag
- func (fs Flags) ResolveSendArgs(args *emul.SendArgs) (err error)
- func (fs Flags) SetActiveEndpoint(eptIdx uint)
- func (fs Flags) SetExplicit()
- type ID
- type StrVal
- type UintVal
Constants ¶
This section is empty.
Variables ¶
var Con cui.Consoler
Con Consoler interface implementation.
var ConfigCmd = &cobra.Command{ Use: "config SUBCOMMAND", DisableFlagsInUseLine: true, Short: "Manage slingconfig settings", Long: "Manage slingconfig settings", Example: ` # View slingconfig settings sling config view`, }
ConfigCmd command.
var Events = [...]string{
"unknows_event",
"console_set_flat",
"log_set_level",
"console_set_level",
"wildcard_set",
"active_enpoint_set",
}
Events event names
var LogCmd = &cobra.Command{ Use: "log SUBCOMMAND", DisableFlagsInUseLine: true, Short: "Manage sling logs", Long: ` Manage sling log file`, Example: ` # View sling log file sling log view # Clean sling log file sling log clean # Log and Console levels PanicLevel [0]: Highest level of severity FatalLevel [1]: Logs and then calls logger.Exit(1). ErrorLevel [2]: Used for errors that should definitely be noted. WarnLevel [3]: Non-critical entries that deserve eyes. InfoLevel [4]: General operational entries about what's going on inside the application. DebugLevel [5]: Usually only enabled when debugging. Very verbose logging. TraceLevel [6]: Designates finer-grained informational events than the Debug.`, }
LogCmd command.
var LogcleanCmd = &cobra.Command{
Use: "clean",
Short: "Clean sling log file",
Long: `
Clean sling log file`,
Example: `
# Clean sling log file using Linux truncate command
sling log clean`,
Run: logcleanRun,
}
LogcleanCmd command.
var LogviewCmd = &cobra.Command{
Use: "view",
Short: "View sling log file",
Long: `
View sling log file`,
Example: `
# View sling log using Linux cat command
sling log view`,
Run: logviewRun,
}
LogviewCmd command.
var RequestCmd = &cobra.Command{ Use: "request SUBCOMMAND", DisableFlagsInUseLine: true, Short: "Process sling requests", Long: ` Sling request managment`, Example: ` Send a single request. sling request send --filename=m000001-tpf-request.dat`, }
RequestCmd command.
var RootCmd = &cobra.Command{ Use: "sling", DisableFlagsInUseLine: true, Short: "sling network traffic emulator", Long: ` sling is a tool to send files to the endpoint(s), setting trottling and delays between concurrent requests.`, Example: ` # View current sling config sling config view # Send a single file to specified endpoint sling request send -f myfile.dat -a myhost.com -p 9080`, }
RootCmd sling root command
var SessionID string
SessionID Send command session ID
var ViewCmd = &cobra.Command{
Use: "view",
Short: "View slingconfig settings",
Long: `
View slingconfig settings`,
Example: `
# View current slingconfig settings
sling config view`,
Run: viewRun,
}
ViewCmd command.
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately.
func LoadConfig ¶
LoadConfig loads configuration from the file.
func NewSendEmul ¶
NewSendEmul creates new send emulator.
Types ¶
type EventID ¶
type EventID int
EventID enum
const ( // UnknownEvent unknown event UnknownEvent EventID = iota // ConsoleSetFlat sets console output flat with no timestamp or fields ConsoleSetFlat // LogSetLevel sets log level LogSetLevel // ConsoleSetLevel sets console level ConsoleSetLevel // WildcardSet sets the wildcard flag WildcardSet // ActiveEndpointSet sent the active enpoint index ActiveEndpointSet )
type Flag ¶
type Flag struct { ID FlagID Name string Shorthand string Usage string Flagset *Flags Type FlagType Value interface{} Event *event.Dispatcher }
A Flag represents the state of a flag.
func NewFlagBool ¶
NewFlagBool returns a new bool flag.
func NewFlagStr ¶
NewFlagStr returns a new string flag.
func NewFlagUint ¶
NewFlagUint returns a new uint flag.
func (Flag) AddEvent ¶
func (f Flag) AddEvent(name interface{}, performing interface{}, parameters ...interface{}) (flag bool, err error)
AddEvent adds flag event
func (*Flag) EqualDefault ¶
EqualDefault returns bool if value is equal.
type FlagID ¶
type FlagID int
FlagID enum
const ( // UnknownFlag unknown flag, " ", Unknown Flag. UnknownFlag FlagID = iota // Address endpoint IP, DNS name, or HTTP address, -a, --address Address // CltType network client type, TCP or HttpPost, -c, --cltType CltType // ConHis write histogram to console, -y, --conHis ConHis // CxnLim limit the number of concurrent connections, -l, cxnLim CxnLim // CxnNum number of concurrent connections, -n, --cxnNum CxnNum // Dir directory to send files from, -d, --dir Dir // Endpoint active endpoint index in SLINGCONFIG, zero-based, -i, --endpont Endpoint // File file path or filename to send, -f, --file File // LogHis write histogram to log file, -g, --logHis LogHis // Port endpoint port number, -p, --port Port // RateMin send rate per minute, -m, --rateMin RateMin // RateSec send rate per second, -s, --rateSec RateSec // Repeat send repeat count, -r, --repeat Repeat // SaveReq save requests, -q, --saveReq SaveReq // SaveReqDir directory to save requests, -k, --saveReqDir SaveReqDir // SaveRes save responses, -o, --saveRes SaveRes // SaveResDir directory to save response, -j, --saveResDir SaveResDir // SleepMs delay after each repeated request, -e, --sleepMs SleepMs // TmoCxn network client dial timeout, -u, --tmoCxn TmoCxn // TmoRdS network client timeout for Read calls, -v, tmoRdS TmoRdS // TmoSec network client timeout, -t, --tmoSec TmoSec // TmoWrS network client timeout for Write calls, -x, --tmoWrS TmoWrS // Wildcard file name matching wildcard, -w, --wildcard Wildcard // ConFlat set console flat output without timestamp and fields, - , --conFlat ConFlat // ConLvl console output level, --, conLvl ConLvl // LogLvl log output level, --, logLvl LogLvl )
type Flagmapper ¶
type Flagmapper interface { SetExplicit() Add(flag *Flag, persist bool) GetFlagmap() map[FlagID]*Flag GetExplicit() map[FlagID]*Flag ResolveSendArgs(args *emul.SendArgs) (err error) AddEvent(flagID FlagID, name interface{}, performing interface{}, parameters ...interface{}) (flag bool, err error) SetActiveEndpoint(eptIdx uint) }
Flagmapper builds command flags.
var RootFlags Flagmapper
RootFlags command flags
func NewCmdFlags ¶
func NewCmdFlags(cmd *cobra.Command, id ID, slconf *conf.SlingConfig) (flagmapper Flagmapper, err error)
NewCmdFlags adds all command flags for the specific command by ID.
func NewFlagMap ¶
func NewFlagMap(cmd *cobra.Command, filer sio.Filer) Flagmapper
NewFlagMap creates a new Flagmapper instance.
type Flags ¶
type Flags struct { Command *cobra.Command Map map[FlagID]*Flag Explicit map[FlagID]*Flag Filer sio.Filer Flagmapper Flagmapper }
Flags has all command flags.
func (Flags) AddEvent ¶
func (fs Flags) AddEvent(flagID FlagID, name interface{}, performing interface{}, parameters ...interface{}) (flag bool, err error)
AddEvent adds flag event.
func (Flags) GetExplicit ¶
GetExplicit returns the explicit flag map.
func (Flags) GetFlagmap ¶
GetFlagmap returns the flag map.
func (Flags) ResolveSendArgs ¶
ResolveSendArgs resolves send arguments from command flags.
func (Flags) SetActiveEndpoint ¶
SetActiveEndpoint sets active endpoint
func (Flags) SetExplicit ¶
func (fs Flags) SetExplicit()
SetExplicit finds the flags set explicitly and addes them to the Explicit map.