1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/config/source/memory
Asim Aslam 0c2041e439
add events package (#2341)
* add events package

* update go version
2021-11-08 08:52:39 +00:00
..
memory.go add events package (#2341) 2021-11-08 08:52:39 +00:00
options.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
README.md Update config source README file 2019-09-04 15:49:58 +08:00
watcher.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +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 memory source
conf.Load(memorySource)