Documentation ¶
Overview ¶
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- type EnvSource
- func (es EnvSource) Close()
- func (es EnvSource) GetConfigurationByKey(key string) (string, error)
- func (es EnvSource) GetConfigurations() (map[string]string, error)
- func (es EnvSource) GetPriority() int
- func (es EnvSource) GetSourceName() string
- func (es EnvSource) SetEventHandler(eh EventHandler)
- func (es EnvSource) UpdateOptions(opts Options)
- type EtcdInfo
- type EtcdSource
- func (es *EtcdSource) Close()
- func (es *EtcdSource) GetConfigurationByKey(key string) (string, error)
- func (es *EtcdSource) GetConfigurations() (map[string]string, error)
- func (es *EtcdSource) GetPriority() int
- func (es *EtcdSource) GetSourceName() string
- func (es *EtcdSource) SetEventHandler(eh EventHandler)
- func (es *EtcdSource) UpdateOptions(opts Options)
- type Event
- type EventDispatcher
- type EventHandler
- type FileInfo
- type FileSource
- func (fs *FileSource) Close()
- func (fs *FileSource) GetConfigurationByKey(key string) (string, error)
- func (fs *FileSource) GetConfigurations() (map[string]string, error)
- func (fs *FileSource) GetPriority() int
- func (fs *FileSource) GetSourceName() string
- func (fs *FileSource) SetEventHandler(eh EventHandler)
- func (fs *FileSource) UpdateOptions(opts Options)
- type Filter
- type Manager
- func (m *Manager) AddSource(source Source) error
- func (m *Manager) Close()
- func (m *Manager) DeleteConfig(key string)
- func (m *Manager) FileConfigs() map[string]string
- func (m *Manager) ForbidUpdate(key string)
- func (m *Manager) GetBy(filters ...Filter) map[string]string
- func (m *Manager) GetConfig(key string) (string, error)
- func (m *Manager) GetConfigs() map[string]string
- func (m *Manager) GetIdentifier() string
- func (m *Manager) OnEvent(event *Event)
- func (m *Manager) ResetConfig(key string)
- func (m *Manager) SetConfig(key, value string)
- func (m *Manager) UpdateSourceOptions(opts ...Option)
- type Option
- type Options
- type Source
Constants ¶
const ( UpdateType = "UPDATE" DeleteType = "DELETE" CreateType = "CREATE" )
Event Constant
const ( HighPriority = 1 NormalPriority = HighPriority + 10 LowPriority = NormalPriority + 10 )
const (
ReadConfigTimeout = 3 * time.Second
)
const (
TombValue = "TOMB_VAULE"
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type EnvSource ¶
type EnvSource struct { KeyFormatter func(string) string // contains filtered or unexported fields }
func NewEnvSource ¶
func (EnvSource) GetConfigurationByKey ¶
GetConfigurationByKey implements ConfigSource
func (EnvSource) GetConfigurations ¶
GetConfigurations implements ConfigSource
func (EnvSource) GetPriority ¶
GetPriority implements ConfigSource
func (EnvSource) GetSourceName ¶
GetSourceName implements ConfigSource
func (EnvSource) SetEventHandler ¶
func (es EnvSource) SetEventHandler(eh EventHandler)
func (EnvSource) UpdateOptions ¶
type EtcdInfo ¶
type EtcdInfo struct { UseEmbed bool UseSSL bool Endpoints []string KeyPrefix string CertFile string KeyFile string CaCertFile string MinVersion string //Pull Configuration interval, unit is second RefreshInterval time.Duration }
EtcdInfo has attribute for config center source initialization
type EtcdSource ¶
func NewEtcdSource ¶
func NewEtcdSource(etcdInfo *EtcdInfo) (*EtcdSource, error)
func (*EtcdSource) Close ¶
func (es *EtcdSource) Close()
func (*EtcdSource) GetConfigurationByKey ¶
func (es *EtcdSource) GetConfigurationByKey(key string) (string, error)
GetConfigurationByKey implements ConfigSource
func (*EtcdSource) GetConfigurations ¶
func (es *EtcdSource) GetConfigurations() (map[string]string, error)
GetConfigurations implements ConfigSource
func (*EtcdSource) GetPriority ¶
func (es *EtcdSource) GetPriority() int
GetPriority implements ConfigSource
func (*EtcdSource) GetSourceName ¶
func (es *EtcdSource) GetSourceName() string
GetSourceName implements ConfigSource
func (*EtcdSource) SetEventHandler ¶
func (es *EtcdSource) SetEventHandler(eh EventHandler)
func (*EtcdSource) UpdateOptions ¶
func (es *EtcdSource) UpdateOptions(opts Options)
type EventDispatcher ¶
type EventDispatcher struct {
// contains filtered or unexported fields
}
func NewEventDispatcher ¶
func NewEventDispatcher() *EventDispatcher
func (*EventDispatcher) Dispatch ¶
func (ed *EventDispatcher) Dispatch(event *Event)
func (*EventDispatcher) Get ¶
func (ed *EventDispatcher) Get(key string) []EventHandler
func (*EventDispatcher) Register ¶
func (ed *EventDispatcher) Register(key string, handler EventHandler)
register a handler to watch specific config changed
func (*EventDispatcher) Unregister ¶
func (ed *EventDispatcher) Unregister(key string, handler EventHandler)
type EventHandler ¶
EventHandler handles config change event
func NewHandler ¶
func NewHandler(ident string, onEvent func(*Event)) EventHandler
type FileSource ¶
func NewFileSource ¶
func NewFileSource(fileInfo *FileInfo) *FileSource
func (*FileSource) Close ¶
func (fs *FileSource) Close()
func (*FileSource) GetConfigurationByKey ¶
func (fs *FileSource) GetConfigurationByKey(key string) (string, error)
GetConfigurationByKey implements ConfigSource
func (*FileSource) GetConfigurations ¶
func (fs *FileSource) GetConfigurations() (map[string]string, error)
GetConfigurations implements ConfigSource
func (*FileSource) GetPriority ¶
func (fs *FileSource) GetPriority() int
GetPriority implements ConfigSource
func (*FileSource) GetSourceName ¶
func (fs *FileSource) GetSourceName() string
GetSourceName implements ConfigSource
func (*FileSource) SetEventHandler ¶
func (fs *FileSource) SetEventHandler(eh EventHandler)
func (*FileSource) UpdateOptions ¶
func (fs *FileSource) UpdateOptions(opts Options)
type Manager ¶
type Manager struct { sync.RWMutex Dispatcher *EventDispatcher // contains filtered or unexported fields }
func NewManager ¶
func NewManager() *Manager
func (*Manager) DeleteConfig ¶
Delete config at runtime, which has the highest priority to override all other sources
func (*Manager) FileConfigs ¶
func (*Manager) ForbidUpdate ¶
Ignore any of update events, which means the config cannot auto refresh anymore
func (*Manager) GetConfigs ¶
GetConfigs returns all the key values
func (*Manager) GetIdentifier ¶
func (*Manager) ResetConfig ¶
Remove the config which set at runtime, use config from sources
func (*Manager) SetConfig ¶
Update config at runtime, which can be called by others The most used scenario is UT
func (*Manager) UpdateSourceOptions ¶
type Option ¶
type Option func(options *Options)
Option is a func
func WithEnvSource ¶
WithEnvSource enable env source archaius will read ENV as key value
func WithEtcdSource ¶
WithEtcdSource accept the information for initiating a remote source
func WithFilesSource ¶
WithRequiredFiles tell archaius to manage files, if not exist will return error