micro/config/source/memory
2019-08-09 12:45:59 +08:00
..
memory.go Move sync deps, change uuid to google and update go.mod 2019-06-07 13:53:42 +01:00
options.go update source 2019-05-31 15:59:21 +01:00
README.md no more WithData method, instead of WithJSON 2019-08-09 12:45:59 +08:00
watcher.go add config 2019-05-30 23:11:13 +01:00

Memory Source

The memory source provides in-memory data as a source

Memory Format

The expected data format is json

data := []byte(`{
    "hosts": {
        "database": {
            "address": "10.0.0.1",
            "port": 3306
        },
        "cache": {
            "address": "10.0.0.2",
            "port": 6379
        }
    }
}`)

New Source

Specify source with data

memorySource := memory.NewSource(
	memory.WithJSON(data),
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load file source
conf.Load(memorySource)