micro/config/source/memory
sunfuze 2efb459c66
Fix config watch (#1670)
* add dirty overrite test case

* need version to figure out if config need update or not

* using nanosecond as version for two goroutine can run in same second

* config should check snapshot version when update

* set checksum of ChangeSet

Co-authored-by: Asim Aslam <asim@aslam.me>
2020-06-16 17:10:52 +01:00
..
memory.go Fix config watch (#1670) 2020-06-16 17:10:52 +01:00
options.go fix import paths for v2 release 2020-01-30 14:44:40 +03:00
README.md Update config source README file 2019-09-04 15:49:58 +08:00
watcher.go fix import paths for v2 release 2020-01-30 14:44:40 +03: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)