2019-05-31 00:11:13 +02:00
|
|
|
# Memory Source
|
|
|
|
|
|
|
|
The memory source provides in-memory data as a source
|
|
|
|
|
|
|
|
## Memory Format
|
|
|
|
|
|
|
|
The expected data format is json
|
|
|
|
|
|
|
|
```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
|
|
|
|
|
|
|
|
```go
|
|
|
|
memorySource := memory.NewSource(
|
2019-08-09 06:45:59 +02:00
|
|
|
memory.WithJSON(data),
|
2019-05-31 00:11:13 +02:00
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Load Source
|
|
|
|
|
|
|
|
Load the source into config
|
|
|
|
|
|
|
|
```go
|
|
|
|
// Create new config
|
|
|
|
conf := config.NewConfig()
|
|
|
|
|
2019-09-04 09:49:58 +02:00
|
|
|
// Load memory source
|
2019-05-31 00:11:13 +02:00
|
|
|
conf.Load(memorySource)
|
|
|
|
```
|