MCPcopy Index your code
hub / github.com/foxcpp/maddy / DataSize

Method DataSize

framework/config/map.go:288–307  ·  view source on GitHub ↗

DataSize maps configuration directive to a int variable, representing data size. Syntax requires unit suffix to be added to the end of string to specify data unit and allows multiple arguments (they will be added together). See Map.Custom for description of arguments.

(name string, inheritGlobal, required bool, defaultVal int64, store *int64)

Source from the content-addressed store, hash-verified

286//
287// See Map.Custom for description of arguments.
288func (m *Map) DataSize(name string, inheritGlobal, required bool, defaultVal int64, store *int64) {
289 m.Custom(name, inheritGlobal, required, func() (interface{}, error) {
290 return defaultVal, nil
291 }, func(_ *Map, node Node) (interface{}, error) {
292 if len(node.Children) != 0 {
293 return nil, NodeErr(node, "can't declare block here")
294 }
295 if len(node.Args) == 0 {
296 return nil, NodeErr(node, "at least one argument is required")
297 }
298
299 durationStr := strings.Join(node.Args, " ")
300 dur, err := ParseDataSize(durationStr)
301 if err != nil {
302 return nil, NodeErr(node, "%v", err)
303 }
304
305 return int64(dur), nil
306 }, store)
307}
308
309func ParseBool(s string) (bool, error) {
310 switch strings.ToLower(s) {

Callers 2

setConfigMethod · 0.80
ConfigureMethod · 0.80

Calls 3

CustomMethod · 0.95
ParseDataSizeFunction · 0.85
NodeErrFunction · 0.70

Tested by

no test coverage detected