github.com/awesome-flow/flow@v0.0.3-0.20190918184116-508d75d68a2c/pkg/cast/schema.go (about)

     1  package cast
     2  
     3  // Schema is a pretty flexible structure for schema definitions.
     4  // It might be:
     5  // * a Mapper
     6  // * a Converter
     7  // * a map[string]Schema
     8  type Schema interface{}
     9  
    10  var (
    11  	// ConfigSchema defines the global flow configuration schema.
    12  	// The settings defined here are system-wide and system modules reply
    13  	// upon that.
    14  	ConfigSchema Schema
    15  )
    16  
    17  func init() {
    18  	ConfigSchema = Schema(map[string]Schema{
    19  		"__self__": nil,
    20  		"system": map[string]Schema{
    21  			"__self__": &CfgBlockSystemMapper{},
    22  			"maxprocs": ToInt,
    23  			"admin": map[string]Schema{
    24  				"__self__": &CfgBlockSystemAdminMapper{},
    25  				"enabled":  ToBool,
    26  				"bind":     ToStr,
    27  			},
    28  			"metrics": map[string]Schema{
    29  				"__self__": &CfgBlockSystemMetricsMapper{},
    30  				"enabled":  ToBool,
    31  				"interval": ToInt,
    32  				"receiver": map[string]Schema{
    33  					"__self__": &CfgBlockSystemMetricsReceiverMapper{},
    34  					"type":     ToStr,
    35  					"params": map[string]Schema{
    36  						"__self__": nil,
    37  						"*":        Identity,
    38  					},
    39  				},
    40  			},
    41  		},
    42  		"actors": map[string]Schema{
    43  			"__self__": &MapCfgBlockActorMapper{},
    44  			"*": map[string]Schema{
    45  				"__self__": &CfgBlockActorMapper{},
    46  				"builder":  ToStr,
    47  				"module":   ToStr,
    48  				"params": map[string]Schema{
    49  					"__self__": nil,
    50  					"*":        Identity,
    51  				},
    52  			},
    53  		},
    54  		"pipeline": map[string]Schema{
    55  			"__self__": &MapCfgBlockPipelineMapper{},
    56  			"*": map[string]Schema{
    57  				"__self__": &CfgBlockPipelineMapper{},
    58  				"connect":  &ArrStrMapper{},
    59  			},
    60  		},
    61  
    62  		/* non-serialisable attributes */
    63  
    64  		"config": map[string]Schema{
    65  			"__self__": nil,
    66  			"path":     ToStr,
    67  		},
    68  		"plugin": map[string]Schema{
    69  			"__self__": nil,
    70  			"path":     ToStr,
    71  		},
    72  	})
    73  }