id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
127,200 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | GetConfigurations | func (configMgr *ConfigurationManager) GetConfigurations() map[string]interface{} {
config := make(map[string]interface{}, 0)
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
for key, sourceName := range configMgr.ConfigurationMap {
sValue := configMgr.configValueBySource(key, sourceName)
i... | go | func (configMgr *ConfigurationManager) GetConfigurations() map[string]interface{} {
config := make(map[string]interface{}, 0)
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
for key, sourceName := range configMgr.ConfigurationMap {
sValue := configMgr.configValueBySource(key, sourceName)
i... | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"GetConfigurations",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"config",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n\n",
"con... | // GetConfigurations returns all the configurationkeys | [
"GetConfigurations",
"returns",
"all",
"the",
"configurationkeys"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L176-L191 |
127,201 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | GetConfigurationsByDimensionInfo | func (configMgr *ConfigurationManager) GetConfigurationsByDimensionInfo(dimensionInfo string) (map[string]interface{}, error) {
config := make(map[string]interface{}, 0)
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
for key, sourceName := range configMgr.ConfigurationMap {
sValue := config... | go | func (configMgr *ConfigurationManager) GetConfigurationsByDimensionInfo(dimensionInfo string) (map[string]interface{}, error) {
config := make(map[string]interface{}, 0)
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
for key, sourceName := range configMgr.ConfigurationMap {
sValue := config... | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"GetConfigurationsByDimensionInfo",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"config",
":=",
"make",
"(",
"map",
"[",
"stri... | // GetConfigurationsByDimensionInfo returns list of all the configuration for a particular dimensionInfo | [
"GetConfigurationsByDimensionInfo",
"returns",
"list",
"of",
"all",
"the",
"configuration",
"for",
"a",
"particular",
"dimensionInfo"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L194-L209 |
127,202 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | AddDimensionInfo | func (configMgr *ConfigurationManager) AddDimensionInfo(dimensionInfo string) (map[string]string, error) {
config := make(map[string]string, 0)
config, er := configMgr.addDimensionInfo(dimensionInfo)
if er != nil {
openlogging.GetLogger().Errorf("failed to do add dimension info %s", er)
return config, er
}
e... | go | func (configMgr *ConfigurationManager) AddDimensionInfo(dimensionInfo string) (map[string]string, error) {
config := make(map[string]string, 0)
config, er := configMgr.addDimensionInfo(dimensionInfo)
if er != nil {
openlogging.GetLogger().Errorf("failed to do add dimension info %s", er)
return config, er
}
e... | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"AddDimensionInfo",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"config",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
... | // AddDimensionInfo adds the dimensionInfo to the list of which configurations needs to be pulled | [
"AddDimensionInfo",
"adds",
"the",
"dimensionInfo",
"to",
"the",
"list",
"of",
"which",
"configurations",
"needs",
"to",
"be",
"pulled"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L212-L228 |
127,203 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | Refresh | func (configMgr *ConfigurationManager) Refresh(sourceName string) error {
err := configMgr.pullSourceConfigs(sourceName)
if err != nil {
openlogging.GetLogger().Errorf("fail to load configuration of %s source: %s", sourceName, err)
errorMsg := "fail to load configuration of" + sourceName + " source"
return erro... | go | func (configMgr *ConfigurationManager) Refresh(sourceName string) error {
err := configMgr.pullSourceConfigs(sourceName)
if err != nil {
openlogging.GetLogger().Errorf("fail to load configuration of %s source: %s", sourceName, err)
errorMsg := "fail to load configuration of" + sourceName + " source"
return erro... | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"Refresh",
"(",
"sourceName",
"string",
")",
"error",
"{",
"err",
":=",
"configMgr",
".",
"pullSourceConfigs",
"(",
"sourceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"openlogging",
".",
"GetLo... | // Refresh refreshes the full configurations of all the dimnesionInfos | [
"Refresh",
"refreshes",
"the",
"full",
"configurations",
"of",
"all",
"the",
"dimnesionInfos"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L231-L239 |
127,204 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | IsKeyExist | func (configMgr *ConfigurationManager) IsKeyExist(key string) bool {
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
if _, ok := configMgr.ConfigurationMap[key]; ok {
return true
}
return false
} | go | func (configMgr *ConfigurationManager) IsKeyExist(key string) bool {
configMgr.configMapMux.Lock()
defer configMgr.configMapMux.Unlock()
if _, ok := configMgr.ConfigurationMap[key]; ok {
return true
}
return false
} | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"IsKeyExist",
"(",
"key",
"string",
")",
"bool",
"{",
"configMgr",
".",
"configMapMux",
".",
"Lock",
"(",
")",
"\n",
"defer",
"configMgr",
".",
"configMapMux",
".",
"Unlock",
"(",
")",
"\n\n",
"if... | // IsKeyExist check if key exsist in cache | [
"IsKeyExist",
"check",
"if",
"key",
"exsist",
"in",
"cache"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L295-L304 |
127,205 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | GetConfigurationsByKey | func (configMgr *ConfigurationManager) GetConfigurationsByKey(key string) interface{} {
configMgr.configMapMux.Lock()
sourceName, ok := configMgr.ConfigurationMap[key]
configMgr.configMapMux.Unlock()
if !ok {
return nil
}
return configMgr.configValueBySource(key, sourceName)
} | go | func (configMgr *ConfigurationManager) GetConfigurationsByKey(key string) interface{} {
configMgr.configMapMux.Lock()
sourceName, ok := configMgr.ConfigurationMap[key]
configMgr.configMapMux.Unlock()
if !ok {
return nil
}
return configMgr.configValueBySource(key, sourceName)
} | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"GetConfigurationsByKey",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"configMgr",
".",
"configMapMux",
".",
"Lock",
"(",
")",
"\n",
"sourceName",
",",
"ok",
":=",
"configMgr",
".",
"Conf... | // GetConfigurationsByKey returns the value for a particluar key from cache | [
"GetConfigurationsByKey",
"returns",
"the",
"value",
"for",
"a",
"particluar",
"key",
"from",
"cache"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L307-L316 |
127,206 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | GetConfigurationsByKeyAndDimensionInfo | func (configMgr *ConfigurationManager) GetConfigurationsByKeyAndDimensionInfo(dimensionInfo, key string) interface{} {
configMgr.configMapMux.Lock()
sourceName, ok := configMgr.ConfigurationMap[key]
configMgr.configMapMux.Unlock()
if !ok {
return nil
}
return configMgr.configValueBySourceAndDimensionInfo(key,... | go | func (configMgr *ConfigurationManager) GetConfigurationsByKeyAndDimensionInfo(dimensionInfo, key string) interface{} {
configMgr.configMapMux.Lock()
sourceName, ok := configMgr.ConfigurationMap[key]
configMgr.configMapMux.Unlock()
if !ok {
return nil
}
return configMgr.configValueBySourceAndDimensionInfo(key,... | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"GetConfigurationsByKeyAndDimensionInfo",
"(",
"dimensionInfo",
",",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"configMgr",
".",
"configMapMux",
".",
"Lock",
"(",
")",
"\n",
"sourceName",
",",
"... | // GetConfigurationsByKeyAndDimensionInfo returns the key value for a particular dimensionInfo | [
"GetConfigurationsByKeyAndDimensionInfo",
"returns",
"the",
"key",
"value",
"for",
"a",
"particular",
"dimensionInfo"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L319-L329 |
127,207 | go-chassis/go-archaius | core/config-manager/configurationmanager.go | OnEvent | func (configMgr *ConfigurationManager) OnEvent(event *core.Event) {
err := configMgr.updateEvent(event)
if err != nil {
openlogging.GetLogger().Error("failed in updating event with error: " + err.Error())
}
} | go | func (configMgr *ConfigurationManager) OnEvent(event *core.Event) {
err := configMgr.updateEvent(event)
if err != nil {
openlogging.GetLogger().Error("failed in updating event with error: " + err.Error())
}
} | [
"func",
"(",
"configMgr",
"*",
"ConfigurationManager",
")",
"OnEvent",
"(",
"event",
"*",
"core",
".",
"Event",
")",
"{",
"err",
":=",
"configMgr",
".",
"updateEvent",
"(",
"event",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"openlogging",
".",
"GetLogger... | // OnEvent Triggers actions when an event is generated | [
"OnEvent",
"Triggers",
"actions",
"when",
"an",
"event",
"is",
"generated"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/configurationmanager.go#L439-L444 |
127,208 | go-chassis/go-archaius | options.go | WithDefaultFileHandler | func WithDefaultFileHandler(handler filesource.FileHandler) Option {
return func(options *Options) {
options.FileHandler = handler
}
} | go | func WithDefaultFileHandler(handler filesource.FileHandler) Option {
return func(options *Options) {
options.FileHandler = handler
}
} | [
"func",
"WithDefaultFileHandler",
"(",
"handler",
"filesource",
".",
"FileHandler",
")",
"Option",
"{",
"return",
"func",
"(",
"options",
"*",
"Options",
")",
"{",
"options",
".",
"FileHandler",
"=",
"handler",
"\n",
"}",
"\n",
"}"
] | //WithDefaultFileHandler let user custom handler
//you can decide how to convert file into kv pairs | [
"WithDefaultFileHandler",
"let",
"user",
"custom",
"handler",
"you",
"can",
"decide",
"how",
"to",
"convert",
"file",
"into",
"kv",
"pairs"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/options.go#L72-L76 |
127,209 | go-chassis/go-archaius | options.go | WithConfigCenterSource | func WithConfigCenterSource(cci ConfigCenterInfo, c config.Client) Option {
return func(options *Options) {
options.ConfigCenterInfo = cci
options.ConfigClient = c
}
} | go | func WithConfigCenterSource(cci ConfigCenterInfo, c config.Client) Option {
return func(options *Options) {
options.ConfigCenterInfo = cci
options.ConfigClient = c
}
} | [
"func",
"WithConfigCenterSource",
"(",
"cci",
"ConfigCenterInfo",
",",
"c",
"config",
".",
"Client",
")",
"Option",
"{",
"return",
"func",
"(",
"options",
"*",
"Options",
")",
"{",
"options",
".",
"ConfigCenterInfo",
"=",
"cci",
"\n",
"options",
".",
"Config... | //WithConfigCenterSource accept the information for initiating a config center source,
//ConfigCenterInfo is required if you want to use config center source
//client is optional,if client is nil, archaius will create one based on ConfigCenterInfo
//config client will be injected into config source as a client to inter... | [
"WithConfigCenterSource",
"accept",
"the",
"information",
"for",
"initiating",
"a",
"config",
"center",
"source",
"ConfigCenterInfo",
"is",
"required",
"if",
"you",
"want",
"to",
"use",
"config",
"center",
"source",
"client",
"is",
"optional",
"if",
"client",
"is"... | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/options.go#L82-L87 |
127,210 | go-chassis/go-archaius | options.go | WithFileHandler | func WithFileHandler(h filesource.FileHandler) FileOption {
return func(options *FileOptions) {
options.Handler = h
}
} | go | func WithFileHandler(h filesource.FileHandler) FileOption {
return func(options *FileOptions) {
options.Handler = h
}
} | [
"func",
"WithFileHandler",
"(",
"h",
"filesource",
".",
"FileHandler",
")",
"FileOption",
"{",
"return",
"func",
"(",
"options",
"*",
"FileOptions",
")",
"{",
"options",
".",
"Handler",
"=",
"h",
"\n",
"}",
"\n\n",
"}"
] | //WithFileHandler use custom handler | [
"WithFileHandler",
"use",
"custom",
"handler"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/options.go#L121-L126 |
127,211 | go-chassis/go-archaius | sources/commandline-source/commandlineconfigurationsource.go | NewCommandlineConfigSource | func NewCommandlineConfigSource() core.ConfigSource {
cmdlineConfig := new(CommandLineConfigurationSource)
cmdlineConfig.priority = commandlinePriority
config, err := cmdlineConfig.pullCmdLineConfig()
if err != nil {
openlogging.GetLogger().Error("failed to initialize commandline configurations:" + err.Error())
... | go | func NewCommandlineConfigSource() core.ConfigSource {
cmdlineConfig := new(CommandLineConfigurationSource)
cmdlineConfig.priority = commandlinePriority
config, err := cmdlineConfig.pullCmdLineConfig()
if err != nil {
openlogging.GetLogger().Error("failed to initialize commandline configurations:" + err.Error())
... | [
"func",
"NewCommandlineConfigSource",
"(",
")",
"core",
".",
"ConfigSource",
"{",
"cmdlineConfig",
":=",
"new",
"(",
"CommandLineConfigurationSource",
")",
"\n",
"cmdlineConfig",
".",
"priority",
"=",
"commandlinePriority",
"\n",
"config",
",",
"err",
":=",
"cmdline... | //NewCommandlineConfigSource defines a fucntion used for creating configuration source | [
"NewCommandlineConfigSource",
"defines",
"a",
"fucntion",
"used",
"for",
"creating",
"configuration",
"source"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/commandline-source/commandlineconfigurationsource.go#L45-L56 |
127,212 | go-chassis/go-archaius | sources/commandline-source/commandlineconfigurationsource.go | GetConfigurations | func (confSrc *CommandLineConfigurationSource) GetConfigurations() (map[string]interface{}, error) {
configMap := make(map[string]interface{})
confSrc.Lock()
defer confSrc.Unlock()
for key, value := range confSrc.Configurations {
configMap[key] = value
}
return configMap, nil
} | go | func (confSrc *CommandLineConfigurationSource) GetConfigurations() (map[string]interface{}, error) {
configMap := make(map[string]interface{})
confSrc.Lock()
defer confSrc.Unlock()
for key, value := range confSrc.Configurations {
configMap[key] = value
}
return configMap, nil
} | [
"func",
"(",
"confSrc",
"*",
"CommandLineConfigurationSource",
")",
"GetConfigurations",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"configMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
... | //GetConfigurations gets particular configuration | [
"GetConfigurations",
"gets",
"particular",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/commandline-source/commandlineconfigurationsource.go#L79-L89 |
127,213 | go-chassis/go-archaius | core/event-system/eventsystem.go | NewDispatcher | func NewDispatcher() core.Dispatcher {
dis := new(dispatcher)
//dis.Logger = logger
dis.listeners = make(map[string][]core.EventListener)
return dis
} | go | func NewDispatcher() core.Dispatcher {
dis := new(dispatcher)
//dis.Logger = logger
dis.listeners = make(map[string][]core.EventListener)
return dis
} | [
"func",
"NewDispatcher",
"(",
")",
"core",
".",
"Dispatcher",
"{",
"dis",
":=",
"new",
"(",
"dispatcher",
")",
"\n",
"//dis.Logger = logger",
"dis",
".",
"listeners",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"core",
".",
"EventListener",
")... | // NewDispatcher is a new dispatcher for listeners | [
"NewDispatcher",
"is",
"a",
"new",
"dispatcher",
"for",
"listeners"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/event-system/eventsystem.go#L37-L42 |
127,214 | go-chassis/go-archaius | core/event-system/eventsystem.go | RegisterListener | func (dis *dispatcher) RegisterListener(listenerObj core.EventListener, keys ...string) error {
if listenerObj == nil {
err := errors.New("nil listener")
openlogging.GetLogger().Error("nil listener supplied:" + err.Error())
return errors.New("nil listener")
}
for _, key := range keys {
listenerList, ok := d... | go | func (dis *dispatcher) RegisterListener(listenerObj core.EventListener, keys ...string) error {
if listenerObj == nil {
err := errors.New("nil listener")
openlogging.GetLogger().Error("nil listener supplied:" + err.Error())
return errors.New("nil listener")
}
for _, key := range keys {
listenerList, ok := d... | [
"func",
"(",
"dis",
"*",
"dispatcher",
")",
"RegisterListener",
"(",
"listenerObj",
"core",
".",
"EventListener",
",",
"keys",
"...",
"string",
")",
"error",
"{",
"if",
"listenerObj",
"==",
"nil",
"{",
"err",
":=",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // RegisterListener registers listener for particular configuration | [
"RegisterListener",
"registers",
"listener",
"for",
"particular",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/event-system/eventsystem.go#L45-L72 |
127,215 | go-chassis/go-archaius | core/event-system/eventsystem.go | UnRegisterListener | func (dis *dispatcher) UnRegisterListener(listenerObj core.EventListener, keys ...string) error {
if listenerObj == nil {
return errors.New("nil listener")
}
for _, key := range keys {
listenerList, ok := dis.listeners[key]
if !ok {
continue
}
newListenerList := make([]core.EventListener, 0)
// remo... | go | func (dis *dispatcher) UnRegisterListener(listenerObj core.EventListener, keys ...string) error {
if listenerObj == nil {
return errors.New("nil listener")
}
for _, key := range keys {
listenerList, ok := dis.listeners[key]
if !ok {
continue
}
newListenerList := make([]core.EventListener, 0)
// remo... | [
"func",
"(",
"dis",
"*",
"dispatcher",
")",
"UnRegisterListener",
"(",
"listenerObj",
"core",
".",
"EventListener",
",",
"keys",
"...",
"string",
")",
"error",
"{",
"if",
"listenerObj",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
"... | // UnRegisterListener un-register listener for a particular configuration | [
"UnRegisterListener",
"un",
"-",
"register",
"listener",
"for",
"a",
"particular",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/event-system/eventsystem.go#L75-L99 |
127,216 | go-chassis/go-archaius | core/event-system/eventsystem.go | DispatchEvent | func (dis *dispatcher) DispatchEvent(event *core.Event) error {
if event == nil {
return errors.New("empty event provided")
}
for regKey, listeners := range dis.listeners {
matched, err := regexp.MatchString(regKey, event.Key)
if err != nil {
openlogging.GetLogger().Errorf("regular expresssion for key %s f... | go | func (dis *dispatcher) DispatchEvent(event *core.Event) error {
if event == nil {
return errors.New("empty event provided")
}
for regKey, listeners := range dis.listeners {
matched, err := regexp.MatchString(regKey, event.Key)
if err != nil {
openlogging.GetLogger().Errorf("regular expresssion for key %s f... | [
"func",
"(",
"dis",
"*",
"dispatcher",
")",
"DispatchEvent",
"(",
"event",
"*",
"core",
".",
"Event",
")",
"error",
"{",
"if",
"event",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"for",
"regKey",
",",... | // DispatchEvent sends the action trigger for a particular event on a configuration | [
"DispatchEvent",
"sends",
"the",
"action",
"trigger",
"for",
"a",
"particular",
"event",
"on",
"a",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/event-system/eventsystem.go#L102-L122 |
127,217 | go-chassis/go-archaius | core/config-manager/unmarshal.go | handlePtr | func (cMgr *ConfigurationManager) handlePtr(rValue reflect.Value, tagName string) error {
if rValue.IsNil() {
ptrValue := reflect.New(rValue.Type().Elem())
err := cMgr.unmarshal(ptrValue, getTagKey(tagName, doNotConsiderTag))
if err != nil {
return err
}
if rValue.CanSet() {
rValue.Set(ptrValue)
}
... | go | func (cMgr *ConfigurationManager) handlePtr(rValue reflect.Value, tagName string) error {
if rValue.IsNil() {
ptrValue := reflect.New(rValue.Type().Elem())
err := cMgr.unmarshal(ptrValue, getTagKey(tagName, doNotConsiderTag))
if err != nil {
return err
}
if rValue.CanSet() {
rValue.Set(ptrValue)
}
... | [
"func",
"(",
"cMgr",
"*",
"ConfigurationManager",
")",
"handlePtr",
"(",
"rValue",
"reflect",
".",
"Value",
",",
"tagName",
"string",
")",
"error",
"{",
"if",
"rValue",
".",
"IsNil",
"(",
")",
"{",
"ptrValue",
":=",
"reflect",
".",
"New",
"(",
"rValue",
... | // handle pointer type objects | [
"handle",
"pointer",
"type",
"objects"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L88-L115 |
127,218 | go-chassis/go-archaius | core/config-manager/unmarshal.go | getTagKey | func getTagKey(currentTag, addTag string) string {
if currentTag == doNotConsiderTag && addTag == doNotConsiderTag {
return doNotConsiderTag
} else if currentTag == doNotConsiderTag && addTag != doNotConsiderTag {
return addTag
} else if currentTag != doNotConsiderTag && addTag == doNotConsiderTag {
return cur... | go | func getTagKey(currentTag, addTag string) string {
if currentTag == doNotConsiderTag && addTag == doNotConsiderTag {
return doNotConsiderTag
} else if currentTag == doNotConsiderTag && addTag != doNotConsiderTag {
return addTag
} else if currentTag != doNotConsiderTag && addTag == doNotConsiderTag {
return cur... | [
"func",
"getTagKey",
"(",
"currentTag",
",",
"addTag",
"string",
")",
"string",
"{",
"if",
"currentTag",
"==",
"doNotConsiderTag",
"&&",
"addTag",
"==",
"doNotConsiderTag",
"{",
"return",
"doNotConsiderTag",
"\n",
"}",
"else",
"if",
"currentTag",
"==",
"doNotCon... | // get multi level configuration key | [
"get",
"multi",
"level",
"configuration",
"key"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L118-L128 |
127,219 | go-chassis/go-archaius | core/config-manager/unmarshal.go | handleStruct | func (cMgr *ConfigurationManager) handleStruct(rValue reflect.Value, tagName string) error {
structType := rValue.Type()
numOfField := structType.NumField()
for i := 0; i < numOfField; i++ {
structField := structType.Field(i)
fieldValue := rValue.Field(i)
keyName := cMgr.getKeyName(structField.Name, structFie... | go | func (cMgr *ConfigurationManager) handleStruct(rValue reflect.Value, tagName string) error {
structType := rValue.Type()
numOfField := structType.NumField()
for i := 0; i < numOfField; i++ {
structField := structType.Field(i)
fieldValue := rValue.Field(i)
keyName := cMgr.getKeyName(structField.Name, structFie... | [
"func",
"(",
"cMgr",
"*",
"ConfigurationManager",
")",
"handleStruct",
"(",
"rValue",
"reflect",
".",
"Value",
",",
"tagName",
"string",
")",
"error",
"{",
"structType",
":=",
"rValue",
".",
"Type",
"(",
")",
"\n",
"numOfField",
":=",
"structType",
".",
"N... | // handle struct type object | [
"handle",
"struct",
"type",
"object"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L131-L176 |
127,220 | go-chassis/go-archaius | core/config-manager/unmarshal.go | populateMap | func (cMgr *ConfigurationManager) populateMap(prefix string, mapType reflect.Type, rValues reflect.Value) (reflect.Value, error) {
tagList := cMgr.getTagList(prefix, rValues)
rValuePtr := reflect.New(mapType)
rValue := rValuePtr.Elem()
rValue.Set(reflect.MakeMap(mapType))
//rValue := reflect.MakeMap(mapType)
map... | go | func (cMgr *ConfigurationManager) populateMap(prefix string, mapType reflect.Type, rValues reflect.Value) (reflect.Value, error) {
tagList := cMgr.getTagList(prefix, rValues)
rValuePtr := reflect.New(mapType)
rValue := rValuePtr.Elem()
rValue.Set(reflect.MakeMap(mapType))
//rValue := reflect.MakeMap(mapType)
map... | [
"func",
"(",
"cMgr",
"*",
"ConfigurationManager",
")",
"populateMap",
"(",
"prefix",
"string",
",",
"mapType",
"reflect",
".",
"Type",
",",
"rValues",
"reflect",
".",
"Value",
")",
"(",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"tagList",
":=",
"c... | // generate map from config map | [
"generate",
"map",
"from",
"config",
"map"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L287-L355 |
127,221 | go-chassis/go-archaius | core/config-manager/unmarshal.go | setValue | func (cMgr *ConfigurationManager) setValue(rValue reflect.Value, keyName string) error {
configValue := cMgr.GetConfigurationsByKey(keyName)
if configValue == nil {
return nil
}
// assign value if assignable
configRValue := reflect.ValueOf(configValue)
if configRValue.Kind() != rValue.Kind() {
returnCongValu... | go | func (cMgr *ConfigurationManager) setValue(rValue reflect.Value, keyName string) error {
configValue := cMgr.GetConfigurationsByKey(keyName)
if configValue == nil {
return nil
}
// assign value if assignable
configRValue := reflect.ValueOf(configValue)
if configRValue.Kind() != rValue.Kind() {
returnCongValu... | [
"func",
"(",
"cMgr",
"*",
"ConfigurationManager",
")",
"setValue",
"(",
"rValue",
"reflect",
".",
"Value",
",",
"keyName",
"string",
")",
"error",
"{",
"configValue",
":=",
"cMgr",
".",
"GetConfigurationsByKey",
"(",
"keyName",
")",
"\n",
"if",
"configValue",
... | // set values in object | [
"set",
"values",
"in",
"object"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L480-L503 |
127,222 | go-chassis/go-archaius | core/config-manager/unmarshal.go | getKeyName | func (*ConfigurationManager) getKeyName(fieldName string, fieldTagName reflect.StructTag) string {
tagName := fieldTagName.Get(configClientTag)
if tagName == "-" {
return ignoreField
} else if tagName == "" {
return toSnake(fieldName)
} else if tagName == ",inline" {
tag := strings.Split(tagName, ",")
tagNa... | go | func (*ConfigurationManager) getKeyName(fieldName string, fieldTagName reflect.StructTag) string {
tagName := fieldTagName.Get(configClientTag)
if tagName == "-" {
return ignoreField
} else if tagName == "" {
return toSnake(fieldName)
} else if tagName == ",inline" {
tag := strings.Split(tagName, ",")
tagNa... | [
"func",
"(",
"*",
"ConfigurationManager",
")",
"getKeyName",
"(",
"fieldName",
"string",
",",
"fieldTagName",
"reflect",
".",
"StructTag",
")",
"string",
"{",
"tagName",
":=",
"fieldTagName",
".",
"Get",
"(",
"configClientTag",
")",
"\n",
"if",
"tagName",
"=="... | // get key from tag | [
"get",
"key",
"from",
"tag"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L506-L519 |
127,223 | go-chassis/go-archaius | core/config-manager/unmarshal.go | ToRvalueType | func ToRvalueType(confValue interface{}, convertType reflect.Type) (returnValue reflect.Value, err error) {
castValue := cast.NewValue(confValue, nil)
returnValue = reflect.New(convertType).Elem()
switch convertType.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
returnInt, ... | go | func ToRvalueType(confValue interface{}, convertType reflect.Type) (returnValue reflect.Value, err error) {
castValue := cast.NewValue(confValue, nil)
returnValue = reflect.New(convertType).Elem()
switch convertType.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
returnInt, ... | [
"func",
"ToRvalueType",
"(",
"confValue",
"interface",
"{",
"}",
",",
"convertType",
"reflect",
".",
"Type",
")",
"(",
"returnValue",
"reflect",
".",
"Value",
",",
"err",
"error",
")",
"{",
"castValue",
":=",
"cast",
".",
"NewValue",
"(",
"confValue",
",",... | // ToRvalueType Deserializes the object to a particular type | [
"ToRvalueType",
"Deserializes",
"the",
"object",
"to",
"a",
"particular",
"type"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/config-manager/unmarshal.go#L539-L583 |
127,224 | go-chassis/go-archaius | sources/file-source/file_handler.go | Convert2JavaProps | func Convert2JavaProps(p string, content []byte) (map[string]interface{}, error) {
configMap := make(map[string]interface{})
ss := yaml.MapSlice{}
err := yaml.Unmarshal([]byte(content), &ss)
if err != nil {
return nil, fmt.Errorf("yaml unmarshal [%s] failed, %s", content, err)
}
configMap = retrieveItems("", s... | go | func Convert2JavaProps(p string, content []byte) (map[string]interface{}, error) {
configMap := make(map[string]interface{})
ss := yaml.MapSlice{}
err := yaml.Unmarshal([]byte(content), &ss)
if err != nil {
return nil, fmt.Errorf("yaml unmarshal [%s] failed, %s", content, err)
}
configMap = retrieveItems("", s... | [
"func",
"Convert2JavaProps",
"(",
"p",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"configMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
... | //Convert2JavaProps is a FileHandler
//it convert the yaml content into java props | [
"Convert2JavaProps",
"is",
"a",
"FileHandler",
"it",
"convert",
"the",
"yaml",
"content",
"into",
"java",
"props"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/file-source/file_handler.go#L15-L26 |
127,225 | go-chassis/go-archaius | sources/file-source/file_handler.go | UseFileNameAsKeyContentAsValue | func UseFileNameAsKeyContentAsValue(p string, content []byte) (map[string]interface{}, error) {
_, filename := filepath.Split(p)
configMap := make(map[string]interface{})
configMap[filename] = content
return configMap, nil
} | go | func UseFileNameAsKeyContentAsValue(p string, content []byte) (map[string]interface{}, error) {
_, filename := filepath.Split(p)
configMap := make(map[string]interface{})
configMap[filename] = content
return configMap, nil
} | [
"func",
"UseFileNameAsKeyContentAsValue",
"(",
"p",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"_",
",",
"filename",
":=",
"filepath",
".",
"Split",
"(",
"p",
")",
"... | //UseFileNameAsKeyContentAsValue is a FileHandler, it sets the yaml file name as key and the content as value | [
"UseFileNameAsKeyContentAsValue",
"is",
"a",
"FileHandler",
"it",
"sets",
"the",
"yaml",
"file",
"name",
"as",
"key",
"and",
"the",
"content",
"as",
"value"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/file-source/file_handler.go#L51-L56 |
127,226 | go-chassis/go-archaius | sources/file-source/file_handler.go | Convert2configMap | func Convert2configMap(p string, content []byte) (map[string]interface{}, error) {
return UseFileNameAsKeyContentAsValue(p, content)
} | go | func Convert2configMap(p string, content []byte) (map[string]interface{}, error) {
return UseFileNameAsKeyContentAsValue(p, content)
} | [
"func",
"Convert2configMap",
"(",
"p",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"UseFileNameAsKeyContentAsValue",
"(",
"p",
",",
"content",
")",
"\n",
"}"
] | //Convert2configMap is legacy API | [
"Convert2configMap",
"is",
"legacy",
"API"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/file-source/file_handler.go#L59-L61 |
127,227 | go-chassis/go-archaius | sources/configcenter/watcher.go | Cleanup | func (dynHandler *DynamicConfigHandler) Cleanup() error {
dynHandler.dynamicLock.Lock()
defer dynHandler.dynamicLock.Unlock()
if dynHandler.wsConnection != nil {
dynHandler.wsConnection.Close()
}
dynHandler.wsConnection = nil
return nil
} | go | func (dynHandler *DynamicConfigHandler) Cleanup() error {
dynHandler.dynamicLock.Lock()
defer dynHandler.dynamicLock.Unlock()
if dynHandler.wsConnection != nil {
dynHandler.wsConnection.Close()
}
dynHandler.wsConnection = nil
return nil
} | [
"func",
"(",
"dynHandler",
"*",
"DynamicConfigHandler",
")",
"Cleanup",
"(",
")",
"error",
"{",
"dynHandler",
".",
"dynamicLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"dynHandler",
".",
"dynamicLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"dynHandler",
"."... | //Cleanup cleans particular dynamic configuration Handler up | [
"Cleanup",
"cleans",
"particular",
"dynamic",
"configuration",
"Handler",
"up"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/watcher.go#L43-L51 |
127,228 | go-chassis/go-archaius | archaius.go | Init | func Init(opts ...Option) error {
if running {
openlogging.Debug("can not init archaius again, call Clean first")
return nil
}
var err error
o := &Options{}
for _, opt := range opts {
opt(o)
}
// created config factory object
factory, err = NewConfigFactory()
if err != nil {
return err
}
factory.De... | go | func Init(opts ...Option) error {
if running {
openlogging.Debug("can not init archaius again, call Clean first")
return nil
}
var err error
o := &Options{}
for _, opt := range opts {
opt(o)
}
// created config factory object
factory, err = NewConfigFactory()
if err != nil {
return err
}
factory.De... | [
"func",
"Init",
"(",
"opts",
"...",
"Option",
")",
"error",
"{",
"if",
"running",
"{",
"openlogging",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"var",
"err",
"error",
"\n",
"o",
":=",
"&",
"Options",
"{",
"}",
"\... | // Init create a Archaius config singleton | [
"Init",
"create",
"a",
"Archaius",
"config",
"singleton"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L58-L115 |
127,229 | go-chassis/go-archaius | archaius.go | EnableConfigCenterSource | func EnableConfigCenterSource(ci ConfigCenterInfo, cc config.Client) error {
if ci == (ConfigCenterInfo{}) {
return errors.New("ConfigCenterInfo can not be empty")
}
if configServerRunning {
openlogging.Debug("can not init config server again, call Clean first")
return nil
}
var err error
if cc == nil {
... | go | func EnableConfigCenterSource(ci ConfigCenterInfo, cc config.Client) error {
if ci == (ConfigCenterInfo{}) {
return errors.New("ConfigCenterInfo can not be empty")
}
if configServerRunning {
openlogging.Debug("can not init config server again, call Clean first")
return nil
}
var err error
if cc == nil {
... | [
"func",
"EnableConfigCenterSource",
"(",
"ci",
"ConfigCenterInfo",
",",
"cc",
"config",
".",
"Client",
")",
"error",
"{",
"if",
"ci",
"==",
"(",
"ConfigCenterInfo",
"{",
"}",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\... | //EnableConfigCenterSource create a config center source singleton
//A config center source pull remote config server key values into local memory
//so that you can use GetXXX to get value easily | [
"EnableConfigCenterSource",
"create",
"a",
"config",
"center",
"source",
"singleton",
"A",
"config",
"center",
"source",
"pull",
"remote",
"config",
"server",
"key",
"values",
"into",
"local",
"memory",
"so",
"that",
"you",
"can",
"use",
"GetXXX",
"to",
"get",
... | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L148-L190 |
127,230 | go-chassis/go-archaius | archaius.go | Event | func (e EventListener) Event(event *core.Event) {
value := e.Factory.GetConfigurationByKey(event.Key)
openlogging.GetLogger().Infof("config value after change %s | %s", event.Key, value)
} | go | func (e EventListener) Event(event *core.Event) {
value := e.Factory.GetConfigurationByKey(event.Key)
openlogging.GetLogger().Infof("config value after change %s | %s", event.Key, value)
} | [
"func",
"(",
"e",
"EventListener",
")",
"Event",
"(",
"event",
"*",
"core",
".",
"Event",
")",
"{",
"value",
":=",
"e",
".",
"Factory",
".",
"GetConfigurationByKey",
"(",
"event",
".",
"Key",
")",
"\n",
"openlogging",
".",
"GetLogger",
"(",
")",
".",
... | // Event is invoked while generating events at run time | [
"Event",
"is",
"invoked",
"while",
"generating",
"events",
"at",
"run",
"time"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L199-L202 |
127,231 | go-chassis/go-archaius | archaius.go | GetBool | func GetBool(key string, defaultValue bool) bool {
b, err := factory.GetValue(key).ToBool()
if err != nil {
return defaultValue
}
return b
} | go | func GetBool(key string, defaultValue bool) bool {
b, err := factory.GetValue(key).ToBool()
if err != nil {
return defaultValue
}
return b
} | [
"func",
"GetBool",
"(",
"key",
"string",
",",
"defaultValue",
"bool",
")",
"bool",
"{",
"b",
",",
"err",
":=",
"factory",
".",
"GetValue",
"(",
"key",
")",
".",
"ToBool",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultValue",
"\n",
... | // GetBool is gives the key value in the form of bool | [
"GetBool",
"is",
"gives",
"the",
"key",
"value",
"in",
"the",
"form",
"of",
"bool"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L220-L226 |
127,232 | go-chassis/go-archaius | archaius.go | GetFloat64 | func GetFloat64(key string, defaultValue float64) float64 {
result, err := factory.GetValue(key).ToFloat64()
if err != nil {
return defaultValue
}
return result
} | go | func GetFloat64(key string, defaultValue float64) float64 {
result, err := factory.GetValue(key).ToFloat64()
if err != nil {
return defaultValue
}
return result
} | [
"func",
"GetFloat64",
"(",
"key",
"string",
",",
"defaultValue",
"float64",
")",
"float64",
"{",
"result",
",",
"err",
":=",
"factory",
".",
"GetValue",
"(",
"key",
")",
".",
"ToFloat64",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaul... | // GetFloat64 gives the key value in the form of float64 | [
"GetFloat64",
"gives",
"the",
"key",
"value",
"in",
"the",
"form",
"of",
"float64"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L229-L235 |
127,233 | go-chassis/go-archaius | archaius.go | GetInt | func GetInt(key string, defaultValue int) int {
result, err := factory.GetValue(key).ToInt()
if err != nil {
return defaultValue
}
return result
} | go | func GetInt(key string, defaultValue int) int {
result, err := factory.GetValue(key).ToInt()
if err != nil {
return defaultValue
}
return result
} | [
"func",
"GetInt",
"(",
"key",
"string",
",",
"defaultValue",
"int",
")",
"int",
"{",
"result",
",",
"err",
":=",
"factory",
".",
"GetValue",
"(",
"key",
")",
".",
"ToInt",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultValue",
"\n",... | // GetInt gives the key value in the form of GetInt | [
"GetInt",
"gives",
"the",
"key",
"value",
"in",
"the",
"form",
"of",
"GetInt"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L238-L244 |
127,234 | go-chassis/go-archaius | archaius.go | GetString | func GetString(key string, defaultValue string) string {
result, err := factory.GetValue(key).ToString()
if err != nil {
return defaultValue
}
return result
} | go | func GetString(key string, defaultValue string) string {
result, err := factory.GetValue(key).ToString()
if err != nil {
return defaultValue
}
return result
} | [
"func",
"GetString",
"(",
"key",
"string",
",",
"defaultValue",
"string",
")",
"string",
"{",
"result",
",",
"err",
":=",
"factory",
".",
"GetValue",
"(",
"key",
")",
".",
"ToString",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultVal... | // GetString gives the key value in the form of GetString | [
"GetString",
"gives",
"the",
"key",
"value",
"in",
"the",
"form",
"of",
"GetString"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L247-L253 |
127,235 | go-chassis/go-archaius | archaius.go | GetStringByDI | func GetStringByDI(dimensionInfo, key string, defaultValue string) string {
result, err := factory.GetValueByDI(dimensionInfo, key).ToString()
if err != nil {
return defaultValue
}
return result
} | go | func GetStringByDI(dimensionInfo, key string, defaultValue string) string {
result, err := factory.GetValueByDI(dimensionInfo, key).ToString()
if err != nil {
return defaultValue
}
return result
} | [
"func",
"GetStringByDI",
"(",
"dimensionInfo",
",",
"key",
"string",
",",
"defaultValue",
"string",
")",
"string",
"{",
"result",
",",
"err",
":=",
"factory",
".",
"GetValueByDI",
"(",
"dimensionInfo",
",",
"key",
")",
".",
"ToString",
"(",
")",
"\n",
"if"... | // GetStringByDI get the value of configuration key in other dimension | [
"GetStringByDI",
"get",
"the",
"value",
"of",
"configuration",
"key",
"in",
"other",
"dimension"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L261-L267 |
127,236 | go-chassis/go-archaius | archaius.go | AddDI | func AddDI(dimensionInfo string) (map[string]string, error) {
config, err := factory.AddByDimensionInfo(dimensionInfo)
return config, err
} | go | func AddDI(dimensionInfo string) (map[string]string, error) {
config, err := factory.AddByDimensionInfo(dimensionInfo)
return config, err
} | [
"func",
"AddDI",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"factory",
".",
"AddByDimensionInfo",
"(",
"dimensionInfo",
")",
"\n",
"return",
"config",
",",
"err",
"\n... | // AddDI adds a NewDimensionInfo of which configurations needs to be taken | [
"AddDI",
"adds",
"a",
"NewDimensionInfo",
"of",
"which",
"configurations",
"needs",
"to",
"be",
"taken"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L275-L278 |
127,237 | go-chassis/go-archaius | archaius.go | RegisterListener | func RegisterListener(listenerObj core.EventListener, key ...string) error {
return factory.RegisterListener(listenerObj, key...)
} | go | func RegisterListener(listenerObj core.EventListener, key ...string) error {
return factory.RegisterListener(listenerObj, key...)
} | [
"func",
"RegisterListener",
"(",
"listenerObj",
"core",
".",
"EventListener",
",",
"key",
"...",
"string",
")",
"error",
"{",
"return",
"factory",
".",
"RegisterListener",
"(",
"listenerObj",
",",
"key",
"...",
")",
"\n",
"}"
] | //RegisterListener to Register all listener for different key changes, each key could be a regular expression | [
"RegisterListener",
"to",
"Register",
"all",
"listener",
"for",
"different",
"key",
"changes",
"each",
"key",
"could",
"be",
"a",
"regular",
"expression"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L281-L283 |
127,238 | go-chassis/go-archaius | archaius.go | UnRegisterListener | func UnRegisterListener(listenerObj core.EventListener, key ...string) error {
return factory.UnRegisterListener(listenerObj, key...)
} | go | func UnRegisterListener(listenerObj core.EventListener, key ...string) error {
return factory.UnRegisterListener(listenerObj, key...)
} | [
"func",
"UnRegisterListener",
"(",
"listenerObj",
"core",
".",
"EventListener",
",",
"key",
"...",
"string",
")",
"error",
"{",
"return",
"factory",
".",
"UnRegisterListener",
"(",
"listenerObj",
",",
"key",
"...",
")",
"\n",
"}"
] | // UnRegisterListener is to remove the listener | [
"UnRegisterListener",
"is",
"to",
"remove",
"the",
"listener"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L286-L288 |
127,239 | go-chassis/go-archaius | archaius.go | AddFile | func AddFile(file string, opts ...FileOption) error {
o := &FileOptions{}
for _, f := range opts {
f(o)
}
if err := fs.AddFile(file, filesource.DefaultFilePriority, o.Handler); err != nil {
return err
}
return factory.Refresh(fs.GetSourceName())
} | go | func AddFile(file string, opts ...FileOption) error {
o := &FileOptions{}
for _, f := range opts {
f(o)
}
if err := fs.AddFile(file, filesource.DefaultFilePriority, o.Handler); err != nil {
return err
}
return factory.Refresh(fs.GetSourceName())
} | [
"func",
"AddFile",
"(",
"file",
"string",
",",
"opts",
"...",
"FileOption",
")",
"error",
"{",
"o",
":=",
"&",
"FileOptions",
"{",
"}",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"opts",
"{",
"f",
"(",
"o",
")",
"\n",
"}",
"\n",
"if",
"err",
":... | // AddFile is for to add the configuration files into the configfactory at run time | [
"AddFile",
"is",
"for",
"to",
"add",
"the",
"configuration",
"files",
"into",
"the",
"configfactory",
"at",
"run",
"time"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L291-L300 |
127,240 | go-chassis/go-archaius | archaius.go | Clean | func Clean() error {
err := factory.DeInit()
if err != nil {
return err
}
running = false
configServerRunning = false
return nil
} | go | func Clean() error {
err := factory.DeInit()
if err != nil {
return err
}
running = false
configServerRunning = false
return nil
} | [
"func",
"Clean",
"(",
")",
"error",
"{",
"err",
":=",
"factory",
".",
"DeInit",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"running",
"=",
"false",
"\n",
"configServerRunning",
"=",
"false",
"\n",
"return",
"nil"... | //Clean will call config manager CleanUp Method,
//it deletes all sources which means all of key value is deleted.
//after you call Clean, you can init archaius again | [
"Clean",
"will",
"call",
"config",
"manager",
"CleanUp",
"Method",
"it",
"deletes",
"all",
"sources",
"which",
"means",
"all",
"of",
"key",
"value",
"is",
"deleted",
".",
"after",
"you",
"call",
"Clean",
"you",
"can",
"init",
"archaius",
"again"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/archaius.go#L326-L334 |
127,241 | go-chassis/go-archaius | examples/hack/main.go | Event | func (e EventListener) Event(event *core.Event) {
configValue := ConfigFactory.GetConfigurationByKey(event.Key)
openlogging.GetLogger().Infof("config value ", event.Key, " | ", configValue)
} | go | func (e EventListener) Event(event *core.Event) {
configValue := ConfigFactory.GetConfigurationByKey(event.Key)
openlogging.GetLogger().Infof("config value ", event.Key, " | ", configValue)
} | [
"func",
"(",
"e",
"EventListener",
")",
"Event",
"(",
"event",
"*",
"core",
".",
"Event",
")",
"{",
"configValue",
":=",
"ConfigFactory",
".",
"GetConfigurationByKey",
"(",
"event",
".",
"Key",
")",
"\n",
"openlogging",
".",
"GetLogger",
"(",
")",
".",
"... | //Event is a method get config value and logs it | [
"Event",
"is",
"a",
"method",
"get",
"config",
"value",
"and",
"logs",
"it"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/examples/hack/main.go#L161-L165 |
127,242 | go-chassis/go-archaius | sources/file-source/filesource.go | NewFileSource | func NewFileSource() FileSource {
if fileConfigSource == nil {
fileConfigSource = new(fileSource)
fileConfigSource.priority = fileSourcePriority
fileConfigSource.files = make([]file, 0)
fileConfigSource.fileHandlers = make(map[string]FileHandler)
}
return fileConfigSource
} | go | func NewFileSource() FileSource {
if fileConfigSource == nil {
fileConfigSource = new(fileSource)
fileConfigSource.priority = fileSourcePriority
fileConfigSource.files = make([]file, 0)
fileConfigSource.fileHandlers = make(map[string]FileHandler)
}
return fileConfigSource
} | [
"func",
"NewFileSource",
"(",
")",
"FileSource",
"{",
"if",
"fileConfigSource",
"==",
"nil",
"{",
"fileConfigSource",
"=",
"new",
"(",
"fileSource",
")",
"\n",
"fileConfigSource",
".",
"priority",
"=",
"fileSourcePriority",
"\n",
"fileConfigSource",
".",
"files",
... | //NewFileSource creates a source which can handler local files | [
"NewFileSource",
"creates",
"a",
"source",
"which",
"can",
"handler",
"local",
"files"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/file-source/filesource.go#L106-L115 |
127,243 | go-chassis/go-archaius | examples/event/event.go | Event | func (e *Listener) Event(event *core.Event) {
openlogging.GetLogger().Info(event.Key)
openlogging.GetLogger().Infof(fmt.Sprintf("%s", event.Value))
openlogging.GetLogger().Info(event.EventType)
} | go | func (e *Listener) Event(event *core.Event) {
openlogging.GetLogger().Info(event.Key)
openlogging.GetLogger().Infof(fmt.Sprintf("%s", event.Value))
openlogging.GetLogger().Info(event.EventType)
} | [
"func",
"(",
"e",
"*",
"Listener",
")",
"Event",
"(",
"event",
"*",
"core",
".",
"Event",
")",
"{",
"openlogging",
".",
"GetLogger",
"(",
")",
".",
"Info",
"(",
"event",
".",
"Key",
")",
"\n",
"openlogging",
".",
"GetLogger",
"(",
")",
".",
"Infof"... | //Event is a method for QPS event listening | [
"Event",
"is",
"a",
"method",
"for",
"QPS",
"event",
"listening"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/examples/event/event.go#L18-L22 |
127,244 | go-chassis/go-archaius | core/cast/cast.go | NewValue | func NewValue(val interface{}, err error) Value {
confVal := new(configValue)
confVal.value = val
confVal.err = err
return confVal
} | go | func NewValue(val interface{}, err error) Value {
confVal := new(configValue)
confVal.value = val
confVal.err = err
return confVal
} | [
"func",
"NewValue",
"(",
"val",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"Value",
"{",
"confVal",
":=",
"new",
"(",
"configValue",
")",
"\n",
"confVal",
".",
"value",
"=",
"val",
"\n",
"confVal",
".",
"err",
"=",
"err",
"\n",
"return",
"confV... | // NewValue creates an object for an interface X | [
"NewValue",
"creates",
"an",
"object",
"for",
"an",
"interface",
"X"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/core/cast/cast.go#L27-L32 |
127,245 | go-chassis/go-archaius | sources/enviromentvariable-source/envconfigurationsource.go | NewEnvConfigurationSource | func NewEnvConfigurationSource() core.ConfigSource {
envConfigSource := new(EnvConfigurationSource)
envConfigSource.priority = envVariableSourcePriority
config, err := envConfigSource.pullConfigurations()
if err != nil {
openlogging.GetLogger().Error("failed to initialize environment configurations: " + err.Error... | go | func NewEnvConfigurationSource() core.ConfigSource {
envConfigSource := new(EnvConfigurationSource)
envConfigSource.priority = envVariableSourcePriority
config, err := envConfigSource.pullConfigurations()
if err != nil {
openlogging.GetLogger().Error("failed to initialize environment configurations: " + err.Error... | [
"func",
"NewEnvConfigurationSource",
"(",
")",
"core",
".",
"ConfigSource",
"{",
"envConfigSource",
":=",
"new",
"(",
"EnvConfigurationSource",
")",
"\n",
"envConfigSource",
".",
"priority",
"=",
"envVariableSourcePriority",
"\n",
"config",
",",
"err",
":=",
"envCon... | //NewEnvConfigurationSource configures a new environment configuration | [
"NewEnvConfigurationSource",
"configures",
"a",
"new",
"environment",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/enviromentvariable-source/envconfigurationsource.go#L45-L56 |
127,246 | go-chassis/go-archaius | sources/configcenter/event_handler.go | OnReceive | func (eventHandler *ConfigCenterEventHandler) OnReceive(sourceConfig map[string]interface{}) {
events, err := eventHandler.ConfigSource.populateEvents(sourceConfig)
if err != nil {
openlogging.GetLogger().Error("error in generating event:" + err.Error())
return
}
openlogging.GetLogger().Debugf("event On Recei... | go | func (eventHandler *ConfigCenterEventHandler) OnReceive(sourceConfig map[string]interface{}) {
events, err := eventHandler.ConfigSource.populateEvents(sourceConfig)
if err != nil {
openlogging.GetLogger().Error("error in generating event:" + err.Error())
return
}
openlogging.GetLogger().Debugf("event On Recei... | [
"func",
"(",
"eventHandler",
"*",
"ConfigCenterEventHandler",
")",
"OnReceive",
"(",
"sourceConfig",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"events",
",",
"err",
":=",
"eventHandler",
".",
"ConfigSource",
".",
"populateEvents",
"(",
"sourc... | //OnReceive initializes all necessary components for a configuration center | [
"OnReceive",
"initializes",
"all",
"necessary",
"components",
"for",
"a",
"configuration",
"center"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/event_handler.go#L28-L42 |
127,247 | go-chassis/go-archaius | configurationfactory.go | NewConfigFactory | func NewConfigFactory() (ConfigurationFactory, error) {
arc := new(ConfigFactory)
//// Source init should be before config manager init
//sources.NewSourceInit()
arc.dispatcher = eventsystem.NewDispatcher()
arc.configMgr = configmanager.NewConfigurationManager(arc.dispatcher)
openlogging.GetLogger().Debug("Confi... | go | func NewConfigFactory() (ConfigurationFactory, error) {
arc := new(ConfigFactory)
//// Source init should be before config manager init
//sources.NewSourceInit()
arc.dispatcher = eventsystem.NewDispatcher()
arc.configMgr = configmanager.NewConfigurationManager(arc.dispatcher)
openlogging.GetLogger().Debug("Confi... | [
"func",
"NewConfigFactory",
"(",
")",
"(",
"ConfigurationFactory",
",",
"error",
")",
"{",
"arc",
":=",
"new",
"(",
"ConfigFactory",
")",
"\n",
"//// Source init should be before config manager init",
"//sources.NewSourceInit()",
"arc",
".",
"dispatcher",
"=",
"eventsys... | // NewConfigFactory creates a new configuration object for config center | [
"NewConfigFactory",
"creates",
"a",
"new",
"configuration",
"object",
"for",
"config",
"center"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L83-L92 |
127,248 | go-chassis/go-archaius | configurationfactory.go | GetConfigurationsByDimensionInfo | func (arc *ConfigFactory) GetConfigurationsByDimensionInfo(dimensionInfo string) map[string]interface{} {
if arc.initSuccess == false {
return nil
}
config, err := arc.configMgr.GetConfigurationsByDimensionInfo(dimensionInfo)
if err != nil {
openlogging.GetLogger().Errorf("Failed to get the configuration by di... | go | func (arc *ConfigFactory) GetConfigurationsByDimensionInfo(dimensionInfo string) map[string]interface{} {
if arc.initSuccess == false {
return nil
}
config, err := arc.configMgr.GetConfigurationsByDimensionInfo(dimensionInfo)
if err != nil {
openlogging.GetLogger().Errorf("Failed to get the configuration by di... | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"GetConfigurationsByDimensionInfo",
"(",
"dimensionInfo",
"string",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
... | //GetConfigurationsByDimensionInfo dump complete configuration managed by config-client Only return config Center configurations. | [
"GetConfigurationsByDimensionInfo",
"dump",
"complete",
"configuration",
"managed",
"by",
"config",
"-",
"client",
"Only",
"return",
"config",
"Center",
"configurations",
"."
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L114-L125 |
127,249 | go-chassis/go-archaius | configurationfactory.go | AddByDimensionInfo | func (arc *ConfigFactory) AddByDimensionInfo(dimensionInfo string) (map[string]string, error) {
if arc.initSuccess == false {
return nil, nil
}
config, err := arc.configMgr.AddDimensionInfo(dimensionInfo)
return config, err
} | go | func (arc *ConfigFactory) AddByDimensionInfo(dimensionInfo string) (map[string]string, error) {
if arc.initSuccess == false {
return nil, nil
}
config, err := arc.configMgr.AddDimensionInfo(dimensionInfo)
return config, err
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"AddByDimensionInfo",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
",",
"nil",
... | // AddByDimensionInfo adds a NewDimensionInfo of which configurations needs to be taken | [
"AddByDimensionInfo",
"adds",
"a",
"NewDimensionInfo",
"of",
"which",
"configurations",
"needs",
"to",
"be",
"taken"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L128-L135 |
127,250 | go-chassis/go-archaius | configurationfactory.go | GetConfigurationByKey | func (arc *ConfigFactory) GetConfigurationByKey(key string) interface{} {
if arc.initSuccess == false {
return nil
}
return arc.configMgr.GetConfigurationsByKey(key)
} | go | func (arc *ConfigFactory) GetConfigurationByKey(key string) interface{} {
if arc.initSuccess == false {
return nil
}
return arc.configMgr.GetConfigurationsByKey(key)
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"GetConfigurationByKey",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"arc",
".",
"configMgr",
"."... | // GetConfigurationByKey return all values of different sources | [
"GetConfigurationByKey",
"return",
"all",
"values",
"of",
"different",
"sources"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L138-L144 |
127,251 | go-chassis/go-archaius | configurationfactory.go | GetConfigurationByKeyAndDimensionInfo | func (arc *ConfigFactory) GetConfigurationByKeyAndDimensionInfo(dimensionInfo, key string) interface{} {
if arc.initSuccess == false {
return nil
}
return arc.configMgr.GetConfigurationsByKeyAndDimensionInfo(dimensionInfo, key)
} | go | func (arc *ConfigFactory) GetConfigurationByKeyAndDimensionInfo(dimensionInfo, key string) interface{} {
if arc.initSuccess == false {
return nil
}
return arc.configMgr.GetConfigurationsByKeyAndDimensionInfo(dimensionInfo, key)
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"GetConfigurationByKeyAndDimensionInfo",
"(",
"dimensionInfo",
",",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"ret... | // GetConfigurationByKeyAndDimensionInfo get the value for a key in a particular dimensionInfo | [
"GetConfigurationByKeyAndDimensionInfo",
"get",
"the",
"value",
"for",
"a",
"key",
"in",
"a",
"particular",
"dimensionInfo"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L147-L153 |
127,252 | go-chassis/go-archaius | configurationfactory.go | AddSource | func (arc *ConfigFactory) AddSource(source core.ConfigSource) error {
if source == nil {
return errors.New("source can not be nil")
}
if arc.initSuccess == false {
openlogging.Warn("Plz call factory.Init() first, failed to add source: " + source.GetSourceName())
return nil
}
return arc.configMgr.AddSource(s... | go | func (arc *ConfigFactory) AddSource(source core.ConfigSource) error {
if source == nil {
return errors.New("source can not be nil")
}
if arc.initSuccess == false {
openlogging.Warn("Plz call factory.Init() first, failed to add source: " + source.GetSourceName())
return nil
}
return arc.configMgr.AddSource(s... | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"AddSource",
"(",
"source",
"core",
".",
"ConfigSource",
")",
"error",
"{",
"if",
"source",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"arc",
".",
"i... | // AddSource return all values of different sources | [
"AddSource",
"return",
"all",
"values",
"of",
"different",
"sources"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L156-L166 |
127,253 | go-chassis/go-archaius | configurationfactory.go | IsKeyExist | func (arc *ConfigFactory) IsKeyExist(key string) bool {
if arc.initSuccess == false {
return false
}
return arc.configMgr.IsKeyExist(key)
} | go | func (arc *ConfigFactory) IsKeyExist(key string) bool {
if arc.initSuccess == false {
return false
}
return arc.configMgr.IsKeyExist(key)
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"IsKeyExist",
"(",
"key",
"string",
")",
"bool",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"arc",
".",
"configMgr",
".",
"IsKeyExist",
"(",
"... | // IsKeyExist check existence of key | [
"IsKeyExist",
"check",
"existence",
"of",
"key"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L169-L175 |
127,254 | go-chassis/go-archaius | configurationfactory.go | RegisterListener | func (arc *ConfigFactory) RegisterListener(listenerObj core.EventListener, keys ...string) error {
for _, key := range keys {
_, err := regexp.Compile(key)
if err != nil {
openlogging.GetLogger().Error(fmt.Sprintf("invalid key format for %s key. key registration ignored: %s", key, err))
return fmt.Errorf("in... | go | func (arc *ConfigFactory) RegisterListener(listenerObj core.EventListener, keys ...string) error {
for _, key := range keys {
_, err := regexp.Compile(key)
if err != nil {
openlogging.GetLogger().Error(fmt.Sprintf("invalid key format for %s key. key registration ignored: %s", key, err))
return fmt.Errorf("in... | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"RegisterListener",
"(",
"listenerObj",
"core",
".",
"EventListener",
",",
"keys",
"...",
"string",
")",
"error",
"{",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"_",
",",
"err",
":=",
"regexp",
"... | // RegisterListener Function to Register all listener for different key changes | [
"RegisterListener",
"Function",
"to",
"Register",
"all",
"listener",
"for",
"different",
"key",
"changes"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L178-L188 |
127,255 | go-chassis/go-archaius | configurationfactory.go | DeInit | func (arc *ConfigFactory) DeInit() error {
if arc.initSuccess == false {
return nil
}
arc.initSuccess = false
arc.configMgr.Cleanup()
return nil
} | go | func (arc *ConfigFactory) DeInit() error {
if arc.initSuccess == false {
return nil
}
arc.initSuccess = false
arc.configMgr.Cleanup()
return nil
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"DeInit",
"(",
")",
"error",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"arc",
".",
"initSuccess",
"=",
"false",
"\n",
"arc",
".",
"configMgr",
".",
"Clea... | // DeInit return all values of different sources | [
"DeInit",
"return",
"all",
"values",
"of",
"different",
"sources"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L221-L228 |
127,256 | go-chassis/go-archaius | configurationfactory.go | GetValue | func (arc *ConfigFactory) GetValue(key string) cast.Value {
if arc.initSuccess == false {
return nil
}
var confValue cast.Value
val := arc.GetConfigurationByKey(key)
if val == nil {
confValue = cast.NewValue(nil, errors.New("key does not exist"))
} else {
confValue = cast.NewValue(val, nil)
}
return con... | go | func (arc *ConfigFactory) GetValue(key string) cast.Value {
if arc.initSuccess == false {
return nil
}
var confValue cast.Value
val := arc.GetConfigurationByKey(key)
if val == nil {
confValue = cast.NewValue(nil, errors.New("key does not exist"))
} else {
confValue = cast.NewValue(val, nil)
}
return con... | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"GetValue",
"(",
"key",
"string",
")",
"cast",
".",
"Value",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"confValue",
"cast",
".",
"Value",
"\n",
... | // GetValue an abstraction to return key's value in respective type | [
"GetValue",
"an",
"abstraction",
"to",
"return",
"key",
"s",
"value",
"in",
"respective",
"type"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L231-L245 |
127,257 | go-chassis/go-archaius | configurationfactory.go | GetValueByDI | func (arc *ConfigFactory) GetValueByDI(dimensionInfo, key string) cast.Value {
if arc.initSuccess == false {
return nil
}
var confValue cast.Value
val := arc.GetConfigurationByKeyAndDimensionInfo(dimensionInfo, key)
if val == nil {
confValue = cast.NewValue(nil, errors.New("key does not exist"))
} else {
c... | go | func (arc *ConfigFactory) GetValueByDI(dimensionInfo, key string) cast.Value {
if arc.initSuccess == false {
return nil
}
var confValue cast.Value
val := arc.GetConfigurationByKeyAndDimensionInfo(dimensionInfo, key)
if val == nil {
confValue = cast.NewValue(nil, errors.New("key does not exist"))
} else {
c... | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"GetValueByDI",
"(",
"dimensionInfo",
",",
"key",
"string",
")",
"cast",
".",
"Value",
"{",
"if",
"arc",
".",
"initSuccess",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"confValue",
"cast"... | // GetValueByDI an abstraction to return key's value in respective type based on dimension info which is provided by user | [
"GetValueByDI",
"an",
"abstraction",
"to",
"return",
"key",
"s",
"value",
"in",
"respective",
"type",
"based",
"on",
"dimension",
"info",
"which",
"is",
"provided",
"by",
"user"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L248-L262 |
127,258 | go-chassis/go-archaius | configurationfactory.go | Refresh | func (arc *ConfigFactory) Refresh(name string) error {
return arc.configMgr.Refresh(name)
} | go | func (arc *ConfigFactory) Refresh(name string) error {
return arc.configMgr.Refresh(name)
} | [
"func",
"(",
"arc",
"*",
"ConfigFactory",
")",
"Refresh",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"arc",
".",
"configMgr",
".",
"Refresh",
"(",
"name",
")",
"\n",
"}"
] | //Refresh pull config from source and update configuration map | [
"Refresh",
"pull",
"config",
"from",
"source",
"and",
"update",
"configuration",
"map"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/configurationfactory.go#L265-L267 |
127,259 | go-chassis/go-archaius | sources/memory-source/memorysource.go | NewMemoryConfigurationSource | func NewMemoryConfigurationSource() MemorySource {
memoryConfigSource := new(MemoryConfigurationSource)
memoryConfigSource.priority = memoryVariableSourcePriority
memoryConfigSource.Configurations = make(map[string]interface{})
memoryConfigSource.CallbackCheck = make(chan bool)
return memoryConfigSource
} | go | func NewMemoryConfigurationSource() MemorySource {
memoryConfigSource := new(MemoryConfigurationSource)
memoryConfigSource.priority = memoryVariableSourcePriority
memoryConfigSource.Configurations = make(map[string]interface{})
memoryConfigSource.CallbackCheck = make(chan bool)
return memoryConfigSource
} | [
"func",
"NewMemoryConfigurationSource",
"(",
")",
"MemorySource",
"{",
"memoryConfigSource",
":=",
"new",
"(",
"MemoryConfigurationSource",
")",
"\n",
"memoryConfigSource",
".",
"priority",
"=",
"memoryVariableSourcePriority",
"\n",
"memoryConfigSource",
".",
"Configuration... | //NewMemoryConfigurationSource initializes all necessary components for memory configuration | [
"NewMemoryConfigurationSource",
"initializes",
"all",
"necessary",
"components",
"for",
"memory",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/memory-source/memorysource.go#L54-L60 |
127,260 | go-chassis/go-archaius | sources/memory-source/memorysource.go | DynamicConfigHandler | func (confSrc *MemoryConfigurationSource) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
confSrc.callback = callback
openlogging.Info("mem source callback prepared")
confSrc.CallbackCheck <- true
return nil
} | go | func (confSrc *MemoryConfigurationSource) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
confSrc.callback = callback
openlogging.Info("mem source callback prepared")
confSrc.CallbackCheck <- true
return nil
} | [
"func",
"(",
"confSrc",
"*",
"MemoryConfigurationSource",
")",
"DynamicConfigHandler",
"(",
"callback",
"core",
".",
"DynamicConfigCallback",
")",
"error",
"{",
"confSrc",
".",
"callback",
"=",
"callback",
"\n",
"openlogging",
".",
"Info",
"(",
"\"",
"\"",
")",
... | //DynamicConfigHandler dynamically handles a memory configuration | [
"DynamicConfigHandler",
"dynamically",
"handles",
"a",
"memory",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/memory-source/memorysource.go#L103-L108 |
127,261 | go-chassis/go-archaius | sources/memory-source/memorysource.go | AddKeyValue | func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
if !confSrc.ChanStatus {
<-confSrc.CallbackCheck
confSrc.ChanStatus = true
}
event := new(core.Event)
event.EventSource = confSrc.GetSourceName()
event.Key = key
event.Value = value
confSrc.Lock()
defer confSrc.Un... | go | func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
if !confSrc.ChanStatus {
<-confSrc.CallbackCheck
confSrc.ChanStatus = true
}
event := new(core.Event)
event.EventSource = confSrc.GetSourceName()
event.Key = key
event.Value = value
confSrc.Lock()
defer confSrc.Un... | [
"func",
"(",
"confSrc",
"*",
"MemoryConfigurationSource",
")",
"AddKeyValue",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"confSrc",
".",
"ChanStatus",
"{",
"<-",
"confSrc",
".",
"CallbackCheck",
"\n",
"confSrc",
... | //AddKeyValue creates new configuration for corresponding key and value pair | [
"AddKeyValue",
"creates",
"new",
"configuration",
"for",
"corresponding",
"key",
"and",
"value",
"pair"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/memory-source/memorysource.go#L111-L137 |
127,262 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | NewConfigCenterSource | func NewConfigCenterSource(cc config.Client, dimInfo string,
refreshMode, refreshInterval int) core.ConfigSource {
if ConfigCenterConfig == nil {
ConfigCenterConfig = new(Handler)
ConfigCenterConfig.priority = configCenterSourcePriority
ConfigCenterConfig.cc = cc
ConfigCenterConfig.dimensionsInfo = dimInfo
... | go | func NewConfigCenterSource(cc config.Client, dimInfo string,
refreshMode, refreshInterval int) core.ConfigSource {
if ConfigCenterConfig == nil {
ConfigCenterConfig = new(Handler)
ConfigCenterConfig.priority = configCenterSourcePriority
ConfigCenterConfig.cc = cc
ConfigCenterConfig.dimensionsInfo = dimInfo
... | [
"func",
"NewConfigCenterSource",
"(",
"cc",
"config",
".",
"Client",
",",
"dimInfo",
"string",
",",
"refreshMode",
",",
"refreshInterval",
"int",
")",
"core",
".",
"ConfigSource",
"{",
"if",
"ConfigCenterConfig",
"==",
"nil",
"{",
"ConfigCenterConfig",
"=",
"new... | //NewConfigCenterSource initializes all components of configuration center | [
"NewConfigCenterSource",
"initializes",
"all",
"components",
"of",
"configuration",
"center"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L72-L86 |
127,263 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | GetConfigurations | func (cfgSrcHandler *Handler) GetConfigurations() (map[string]interface{}, error) {
configMap := make(map[string]interface{})
err := cfgSrcHandler.refreshConfigurations("")
if err != nil {
return nil, err
}
if cfgSrcHandler.RefreshMode == 1 {
go cfgSrcHandler.refreshConfigurationsPeriodically("")
}
cfgSrcH... | go | func (cfgSrcHandler *Handler) GetConfigurations() (map[string]interface{}, error) {
configMap := make(map[string]interface{})
err := cfgSrcHandler.refreshConfigurations("")
if err != nil {
return nil, err
}
if cfgSrcHandler.RefreshMode == 1 {
go cfgSrcHandler.refreshConfigurationsPeriodically("")
}
cfgSrcH... | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"GetConfigurations",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"configMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\... | //GetConfigurations gets a particular configuration | [
"GetConfigurations",
"gets",
"a",
"particular",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L95-L112 |
127,264 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | GetConfigurationsByDI | func (cfgSrcHandler *Handler) GetConfigurationsByDI(dimensionInfo string) (map[string]interface{}, error) {
configMap := make(map[string]interface{})
err := cfgSrcHandler.refreshConfigurations(dimensionInfo)
if err != nil {
return nil, err
}
if cfgSrcHandler.RefreshMode == 1 {
go cfgSrcHandler.refreshConfigu... | go | func (cfgSrcHandler *Handler) GetConfigurationsByDI(dimensionInfo string) (map[string]interface{}, error) {
configMap := make(map[string]interface{})
err := cfgSrcHandler.refreshConfigurations(dimensionInfo)
if err != nil {
return nil, err
}
if cfgSrcHandler.RefreshMode == 1 {
go cfgSrcHandler.refreshConfigu... | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"GetConfigurationsByDI",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"configMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"in... | //GetConfigurationsByDI gets required configurations for particular dimension info | [
"GetConfigurationsByDI",
"gets",
"required",
"configurations",
"for",
"particular",
"dimension",
"info"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L115-L133 |
127,265 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | GetConfigurationByKeyAndDimensionInfo | func (cfgSrcHandler *Handler) GetConfigurationByKeyAndDimensionInfo(key, dimensionInfo string) (interface{}, error) {
var (
configSrcVal interface{}
actualValue interface{}
exist bool
)
cfgSrcHandler.Lock()
for _, v := range cfgSrcHandler.dimensionsInfoConfigurations {
value, ok := v[dimensionInfo]... | go | func (cfgSrcHandler *Handler) GetConfigurationByKeyAndDimensionInfo(key, dimensionInfo string) (interface{}, error) {
var (
configSrcVal interface{}
actualValue interface{}
exist bool
)
cfgSrcHandler.Lock()
for _, v := range cfgSrcHandler.dimensionsInfoConfigurations {
value, ok := v[dimensionInfo]... | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"GetConfigurationByKeyAndDimensionInfo",
"(",
"key",
",",
"dimensionInfo",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"(",
"configSrcVal",
"interface",
"{",
"}",
"\n",
"actualVal... | //GetConfigurationByKeyAndDimensionInfo gets required configuration for a particular key and dimension pair | [
"GetConfigurationByKeyAndDimensionInfo",
"gets",
"required",
"configuration",
"for",
"a",
"particular",
"key",
"and",
"dimension",
"pair"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L253-L275 |
127,266 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | AddDimensionInfo | func (cfgSrcHandler *Handler) AddDimensionInfo(dimensionInfo string) (map[string]string, error) {
if len(cfgSrcHandler.dimensionInfoMap) == 0 {
cfgSrcHandler.dimensionInfoMap = make(map[string]string)
}
for i := range cfgSrcHandler.dimensionInfoMap {
if i == dimensionInfo {
openlogging.GetLogger().Errorf("di... | go | func (cfgSrcHandler *Handler) AddDimensionInfo(dimensionInfo string) (map[string]string, error) {
if len(cfgSrcHandler.dimensionInfoMap) == 0 {
cfgSrcHandler.dimensionInfoMap = make(map[string]string)
}
for i := range cfgSrcHandler.dimensionInfoMap {
if i == dimensionInfo {
openlogging.GetLogger().Errorf("di... | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"AddDimensionInfo",
"(",
"dimensionInfo",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"cfgSrcHandler",
".",
"dimensionInfoMap",
")",
"==",
"0",
"{",
... | //AddDimensionInfo adds dimension info for a configuration | [
"AddDimensionInfo",
"adds",
"dimension",
"info",
"for",
"a",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L278-L293 |
127,267 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | DynamicConfigHandler | func (cfgSrcHandler *Handler) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
if cfgSrcHandler.initSuccess != true {
return errors.New("config center source initialization failed")
}
dynCfgHandler, err := newDynConfigHandlerSource(cfgSrcHandler, callback)
if err != nil {
openlogging.GetLogger... | go | func (cfgSrcHandler *Handler) DynamicConfigHandler(callback core.DynamicConfigCallback) error {
if cfgSrcHandler.initSuccess != true {
return errors.New("config center source initialization failed")
}
dynCfgHandler, err := newDynConfigHandlerSource(cfgSrcHandler, callback)
if err != nil {
openlogging.GetLogger... | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"DynamicConfigHandler",
"(",
"callback",
"core",
".",
"DynamicConfigCallback",
")",
"error",
"{",
"if",
"cfgSrcHandler",
".",
"initSuccess",
"!=",
"true",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | //DynamicConfigHandler dynamically handles a configuration | [
"DynamicConfigHandler",
"dynamically",
"handles",
"a",
"configuration"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L311-L331 |
127,268 | go-chassis/go-archaius | sources/configcenter/configcentersource.go | Cleanup | func (cfgSrcHandler *Handler) Cleanup() error {
cfgSrcHandler.connsLock.Lock()
defer cfgSrcHandler.connsLock.Unlock()
if cfgSrcHandler.dynamicConfigHandler != nil {
cfgSrcHandler.dynamicConfigHandler.Cleanup()
}
cfgSrcHandler.dynamicConfigHandler = nil
cfgSrcHandler.Configurations = nil
return nil
} | go | func (cfgSrcHandler *Handler) Cleanup() error {
cfgSrcHandler.connsLock.Lock()
defer cfgSrcHandler.connsLock.Unlock()
if cfgSrcHandler.dynamicConfigHandler != nil {
cfgSrcHandler.dynamicConfigHandler.Cleanup()
}
cfgSrcHandler.dynamicConfigHandler = nil
cfgSrcHandler.Configurations = nil
return nil
} | [
"func",
"(",
"cfgSrcHandler",
"*",
"Handler",
")",
"Cleanup",
"(",
")",
"error",
"{",
"cfgSrcHandler",
".",
"connsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cfgSrcHandler",
".",
"connsLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"cfgSrcHandler",
".",
... | //Cleanup cleans the particular configuration up | [
"Cleanup",
"cleans",
"the",
"particular",
"configuration",
"up"
] | 5b479bcb10437daee44d1d77af651939c6d92541 | https://github.com/go-chassis/go-archaius/blob/5b479bcb10437daee44d1d77af651939c6d92541/sources/configcenter/configcentersource.go#L334-L346 |
127,269 | shogo82148/androidbinary | table.go | ParseResID | func ParseResID(s string) (ResID, error) {
if !IsResID(s) {
return 0, fmt.Errorf("androidbinary: %s is not ResID", s)
}
id, err := strconv.ParseUint(s[3:], 16, 32)
if err != nil {
return 0, err
}
return ResID(id), nil
} | go | func ParseResID(s string) (ResID, error) {
if !IsResID(s) {
return 0, fmt.Errorf("androidbinary: %s is not ResID", s)
}
id, err := strconv.ParseUint(s[3:], 16, 32)
if err != nil {
return 0, err
}
return ResID(id), nil
} | [
"func",
"ParseResID",
"(",
"s",
"string",
")",
"(",
"ResID",
",",
"error",
")",
"{",
"if",
"!",
"IsResID",
"(",
"s",
")",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"id",
",",
"err",
":=",
... | // ParseResID parses ResId. | [
"ParseResID",
"parses",
"ResId",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L192-L201 |
127,270 | shogo82148/androidbinary | table.go | NewTableFile | func NewTableFile(r io.ReaderAt) (*TableFile, error) {
f := new(TableFile)
sr := io.NewSectionReader(r, 0, 1<<63-1)
header := new(ResTableHeader)
binary.Read(sr, binary.LittleEndian, header)
f.tablePackages = make(map[uint32]*TablePackage)
offset := int64(header.Header.HeaderSize)
for offset < int64(header.Hea... | go | func NewTableFile(r io.ReaderAt) (*TableFile, error) {
f := new(TableFile)
sr := io.NewSectionReader(r, 0, 1<<63-1)
header := new(ResTableHeader)
binary.Read(sr, binary.LittleEndian, header)
f.tablePackages = make(map[uint32]*TablePackage)
offset := int64(header.Header.HeaderSize)
for offset < int64(header.Hea... | [
"func",
"NewTableFile",
"(",
"r",
"io",
".",
"ReaderAt",
")",
"(",
"*",
"TableFile",
",",
"error",
")",
"{",
"f",
":=",
"new",
"(",
"TableFile",
")",
"\n",
"sr",
":=",
"io",
".",
"NewSectionReader",
"(",
"r",
",",
"0",
",",
"1",
"<<",
"63",
"-",
... | // NewTableFile returns new TableFile. | [
"NewTableFile",
"returns",
"new",
"TableFile",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L223-L240 |
127,271 | shogo82148/androidbinary | table.go | GetResource | func (f *TableFile) GetResource(id ResID, config *ResTableConfig) (interface{}, error) {
p := f.findPackage(id.Package())
if p == nil {
return nil, fmt.Errorf("androidbinary: package 0x%02X not found", id.Package())
}
e := p.findEntry(id.Type(), id.Entry(), config)
v := e.Value
if v == nil {
return nil, fmt.E... | go | func (f *TableFile) GetResource(id ResID, config *ResTableConfig) (interface{}, error) {
p := f.findPackage(id.Package())
if p == nil {
return nil, fmt.Errorf("androidbinary: package 0x%02X not found", id.Package())
}
e := p.findEntry(id.Type(), id.Entry(), config)
v := e.Value
if v == nil {
return nil, fmt.E... | [
"func",
"(",
"f",
"*",
"TableFile",
")",
"GetResource",
"(",
"id",
"ResID",
",",
"config",
"*",
"ResTableConfig",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"p",
":=",
"f",
".",
"findPackage",
"(",
"id",
".",
"Package",
"(",
")",
")",... | // GetResource returns a resrouce referenced by id. | [
"GetResource",
"returns",
"a",
"resrouce",
"referenced",
"by",
"id",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L272-L295 |
127,272 | shogo82148/androidbinary | table.go | IsLocaleMoreSpecificThan | func (c *ResTableConfig) IsLocaleMoreSpecificThan(o *ResTableConfig) int {
if (c.Language != [2]uint8{} || c.Country != [2]uint8{}) || (o.Language != [2]uint8{} || o.Country != [2]uint8{}) {
if c.Language != o.Language {
if c.Language == [2]uint8{} {
return -1
}
if o.Language == [2]uint8{} {
return ... | go | func (c *ResTableConfig) IsLocaleMoreSpecificThan(o *ResTableConfig) int {
if (c.Language != [2]uint8{} || c.Country != [2]uint8{}) || (o.Language != [2]uint8{} || o.Country != [2]uint8{}) {
if c.Language != o.Language {
if c.Language == [2]uint8{} {
return -1
}
if o.Language == [2]uint8{} {
return ... | [
"func",
"(",
"c",
"*",
"ResTableConfig",
")",
"IsLocaleMoreSpecificThan",
"(",
"o",
"*",
"ResTableConfig",
")",
"int",
"{",
"if",
"(",
"c",
".",
"Language",
"!=",
"[",
"2",
"]",
"uint8",
"{",
"}",
"||",
"c",
".",
"Country",
"!=",
"[",
"2",
"]",
"ui... | // IsLocaleMoreSpecificThan a positive integer if this config is more specific than o,
// a negative integer if |o| is more specific
// and 0 if they're equally specific. | [
"IsLocaleMoreSpecificThan",
"a",
"positive",
"integer",
"if",
"this",
"config",
"is",
"more",
"specific",
"than",
"o",
"a",
"negative",
"integer",
"if",
"|o|",
"is",
"more",
"specific",
"and",
"0",
"if",
"they",
"re",
"equally",
"specific",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L879-L900 |
127,273 | shogo82148/androidbinary | table.go | IsLocaleBetterThan | func (c *ResTableConfig) IsLocaleBetterThan(o *ResTableConfig, r *ResTableConfig) bool {
if r.Language == [2]uint8{} && r.Country == [2]uint8{} {
// The request doesn't have a locale, so no resource is better
// than the other.
return false
}
if c.Language == [2]uint8{} && c.Country == [2]uint8{} && o.Languag... | go | func (c *ResTableConfig) IsLocaleBetterThan(o *ResTableConfig, r *ResTableConfig) bool {
if r.Language == [2]uint8{} && r.Country == [2]uint8{} {
// The request doesn't have a locale, so no resource is better
// than the other.
return false
}
if c.Language == [2]uint8{} && c.Country == [2]uint8{} && o.Languag... | [
"func",
"(",
"c",
"*",
"ResTableConfig",
")",
"IsLocaleBetterThan",
"(",
"o",
"*",
"ResTableConfig",
",",
"r",
"*",
"ResTableConfig",
")",
"bool",
"{",
"if",
"r",
".",
"Language",
"==",
"[",
"2",
"]",
"uint8",
"{",
"}",
"&&",
"r",
".",
"Country",
"==... | // IsLocaleBetterThan returns true if c is a better locale match than o for the r configuration. | [
"IsLocaleBetterThan",
"returns",
"true",
"if",
"c",
"is",
"a",
"better",
"locale",
"match",
"than",
"o",
"for",
"the",
"r",
"configuration",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L903-L936 |
127,274 | shogo82148/androidbinary | table.go | Locale | func (c *ResTableConfig) Locale() string {
if c.Language[0] == 0 {
return ""
}
if c.Country[0] == 0 {
return fmt.Sprintf("%c%c", c.Language[0], c.Language[1])
}
return fmt.Sprintf("%c%c-%c%c", c.Language[0], c.Language[1], c.Country[0], c.Country[1])
} | go | func (c *ResTableConfig) Locale() string {
if c.Language[0] == 0 {
return ""
}
if c.Country[0] == 0 {
return fmt.Sprintf("%c%c", c.Language[0], c.Language[1])
}
return fmt.Sprintf("%c%c-%c%c", c.Language[0], c.Language[1], c.Country[0], c.Country[1])
} | [
"func",
"(",
"c",
"*",
"ResTableConfig",
")",
"Locale",
"(",
")",
"string",
"{",
"if",
"c",
".",
"Language",
"[",
"0",
"]",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"c",
".",
"Country",
"[",
"0",
"]",
"==",
"0",
"{",
"retu... | // Locale returns the locale of the configuration. | [
"Locale",
"returns",
"the",
"locale",
"of",
"the",
"configuration",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/table.go#L1085-L1093 |
127,275 | shogo82148/androidbinary | xml.go | NewXMLFile | func NewXMLFile(r io.ReaderAt) (*XMLFile, error) {
f := new(XMLFile)
sr := io.NewSectionReader(r, 0, 1<<63-1)
fmt.Fprintf(&f.xmlBuffer, xml.Header)
header := new(ResChunkHeader)
if err := binary.Read(sr, binary.LittleEndian, header); err != nil {
return nil, err
}
offset := int64(header.HeaderSize)
for offs... | go | func NewXMLFile(r io.ReaderAt) (*XMLFile, error) {
f := new(XMLFile)
sr := io.NewSectionReader(r, 0, 1<<63-1)
fmt.Fprintf(&f.xmlBuffer, xml.Header)
header := new(ResChunkHeader)
if err := binary.Read(sr, binary.LittleEndian, header); err != nil {
return nil, err
}
offset := int64(header.HeaderSize)
for offs... | [
"func",
"NewXMLFile",
"(",
"r",
"io",
".",
"ReaderAt",
")",
"(",
"*",
"XMLFile",
",",
"error",
")",
"{",
"f",
":=",
"new",
"(",
"XMLFile",
")",
"\n",
"sr",
":=",
"io",
".",
"NewSectionReader",
"(",
"r",
",",
"0",
",",
"1",
"<<",
"63",
"-",
"1",... | // NewXMLFile returns a new XMLFile. | [
"NewXMLFile",
"returns",
"a",
"new",
"XMLFile",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/xml.go#L60-L79 |
127,276 | shogo82148/androidbinary | xml.go | Reader | func (f *XMLFile) Reader() *bytes.Reader {
return bytes.NewReader(f.xmlBuffer.Bytes())
} | go | func (f *XMLFile) Reader() *bytes.Reader {
return bytes.NewReader(f.xmlBuffer.Bytes())
} | [
"func",
"(",
"f",
"*",
"XMLFile",
")",
"Reader",
"(",
")",
"*",
"bytes",
".",
"Reader",
"{",
"return",
"bytes",
".",
"NewReader",
"(",
"f",
".",
"xmlBuffer",
".",
"Bytes",
"(",
")",
")",
"\n",
"}"
] | // Reader returns a reader of XML file expressed in text format. | [
"Reader",
"returns",
"a",
"reader",
"of",
"XML",
"file",
"expressed",
"in",
"text",
"format",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/xml.go#L82-L84 |
127,277 | shogo82148/androidbinary | apk/apk.go | OpenFile | func OpenFile(filename string) (apk *Apk, err error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
f.Close()
}
}()
fi, err := f.Stat()
if err != nil {
return nil, err
}
apk, err = OpenZipReader(f, fi.Size())
if err != nil {
return nil, err
}
apk.... | go | func OpenFile(filename string) (apk *Apk, err error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
f.Close()
}
}()
fi, err := f.Stat()
if err != nil {
return nil, err
}
apk, err = OpenZipReader(f, fi.Size())
if err != nil {
return nil, err
}
apk.... | [
"func",
"OpenFile",
"(",
"filename",
"string",
")",
"(",
"apk",
"*",
"Apk",
",",
"err",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"... | // OpenFile will open the file specified by filename and return Apk | [
"OpenFile",
"will",
"open",
"the",
"file",
"specified",
"by",
"filename",
"and",
"return",
"Apk"
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L30-L50 |
127,278 | shogo82148/androidbinary | apk/apk.go | OpenZipReader | func OpenZipReader(r io.ReaderAt, size int64) (*Apk, error) {
zipreader, err := zip.NewReader(r, size)
if err != nil {
return nil, err
}
apk := &Apk{
zipreader: zipreader,
}
if err = apk.parseManifest(); err != nil {
return nil, errors.Wrap(err, "parse-manifest")
}
if err = apk.parseResources(); err != ni... | go | func OpenZipReader(r io.ReaderAt, size int64) (*Apk, error) {
zipreader, err := zip.NewReader(r, size)
if err != nil {
return nil, err
}
apk := &Apk{
zipreader: zipreader,
}
if err = apk.parseManifest(); err != nil {
return nil, errors.Wrap(err, "parse-manifest")
}
if err = apk.parseResources(); err != ni... | [
"func",
"OpenZipReader",
"(",
"r",
"io",
".",
"ReaderAt",
",",
"size",
"int64",
")",
"(",
"*",
"Apk",
",",
"error",
")",
"{",
"zipreader",
",",
"err",
":=",
"zip",
".",
"NewReader",
"(",
"r",
",",
"size",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // OpenZipReader has same arguments like zip.NewReader | [
"OpenZipReader",
"has",
"same",
"arguments",
"like",
"zip",
".",
"NewReader"
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L53-L68 |
127,279 | shogo82148/androidbinary | apk/apk.go | Close | func (k *Apk) Close() error {
if k.f == nil {
return nil
}
return k.f.Close()
} | go | func (k *Apk) Close() error {
if k.f == nil {
return nil
}
return k.f.Close()
} | [
"func",
"(",
"k",
"*",
"Apk",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"k",
".",
"f",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"k",
".",
"f",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close is avaliable only if apk is created with OpenFile | [
"Close",
"is",
"avaliable",
"only",
"if",
"apk",
"is",
"created",
"with",
"OpenFile"
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L71-L76 |
127,280 | shogo82148/androidbinary | apk/apk.go | Icon | func (k *Apk) Icon(resConfig *androidbinary.ResTableConfig) (image.Image, error) {
iconPath := k.getResource(k.manifest.App.Icon, resConfig)
if androidbinary.IsResID(iconPath) {
return nil, errors.New("unable to convert icon-id to icon path")
}
imgData, err := k.readZipFile(iconPath)
if err != nil {
return nil... | go | func (k *Apk) Icon(resConfig *androidbinary.ResTableConfig) (image.Image, error) {
iconPath := k.getResource(k.manifest.App.Icon, resConfig)
if androidbinary.IsResID(iconPath) {
return nil, errors.New("unable to convert icon-id to icon path")
}
imgData, err := k.readZipFile(iconPath)
if err != nil {
return nil... | [
"func",
"(",
"k",
"*",
"Apk",
")",
"Icon",
"(",
"resConfig",
"*",
"androidbinary",
".",
"ResTableConfig",
")",
"(",
"image",
".",
"Image",
",",
"error",
")",
"{",
"iconPath",
":=",
"k",
".",
"getResource",
"(",
"k",
".",
"manifest",
".",
"App",
".",
... | // Icon returns the icon image of the APK. | [
"Icon",
"returns",
"the",
"icon",
"image",
"of",
"the",
"APK",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L79-L90 |
127,281 | shogo82148/androidbinary | apk/apk.go | Label | func (k *Apk) Label(resConfig *androidbinary.ResTableConfig) (s string, err error) {
s = k.getResource(k.manifest.App.Label, resConfig)
if androidbinary.IsResID(s) {
err = errors.New("unable to convert label-id to string")
}
return
} | go | func (k *Apk) Label(resConfig *androidbinary.ResTableConfig) (s string, err error) {
s = k.getResource(k.manifest.App.Label, resConfig)
if androidbinary.IsResID(s) {
err = errors.New("unable to convert label-id to string")
}
return
} | [
"func",
"(",
"k",
"*",
"Apk",
")",
"Label",
"(",
"resConfig",
"*",
"androidbinary",
".",
"ResTableConfig",
")",
"(",
"s",
"string",
",",
"err",
"error",
")",
"{",
"s",
"=",
"k",
".",
"getResource",
"(",
"k",
".",
"manifest",
".",
"App",
".",
"Label... | // Label returns the label of the APK. | [
"Label",
"returns",
"the",
"label",
"of",
"the",
"APK",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L93-L99 |
127,282 | shogo82148/androidbinary | apk/apk.go | MainActivity | func (k *Apk) MainActivity() (activity string, err error) {
for _, act := range k.manifest.App.Activities {
for _, intent := range act.IntentFilters {
if isMainIntentFilter(intent) {
return act.Name, nil
}
}
}
for _, act := range k.manifest.App.ActivityAliases {
for _, intent := range act.IntentFilte... | go | func (k *Apk) MainActivity() (activity string, err error) {
for _, act := range k.manifest.App.Activities {
for _, intent := range act.IntentFilters {
if isMainIntentFilter(intent) {
return act.Name, nil
}
}
}
for _, act := range k.manifest.App.ActivityAliases {
for _, intent := range act.IntentFilte... | [
"func",
"(",
"k",
"*",
"Apk",
")",
"MainActivity",
"(",
")",
"(",
"activity",
"string",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"act",
":=",
"range",
"k",
".",
"manifest",
".",
"App",
".",
"Activities",
"{",
"for",
"_",
",",
"intent",
":=... | // MainActivity returns the name of the main activity. | [
"MainActivity",
"returns",
"the",
"name",
"of",
"the",
"main",
"activity",
"."
] | 6d4ec43b2255c1fd76350d5833fd286d28f8d350 | https://github.com/shogo82148/androidbinary/blob/6d4ec43b2255c1fd76350d5833fd286d28f8d350/apk/apk.go#L133-L150 |
127,283 | janekolszak/idp | idp.go | NewIDP | func NewIDP(config *IDPConfig) *IDP {
var idp = new(IDP)
idp.config = config
idp.cache = cache.New(config.KeyCacheExpiration, config.CacheCleanupInterval)
idp.cache.OnEvicted(func(key string, value interface{}) { idp.refreshCache(key) })
idp.createChallengeCookieOptions = new(sessions.Options)
idp.createChallen... | go | func NewIDP(config *IDPConfig) *IDP {
var idp = new(IDP)
idp.config = config
idp.cache = cache.New(config.KeyCacheExpiration, config.CacheCleanupInterval)
idp.cache.OnEvicted(func(key string, value interface{}) { idp.refreshCache(key) })
idp.createChallengeCookieOptions = new(sessions.Options)
idp.createChallen... | [
"func",
"NewIDP",
"(",
"config",
"*",
"IDPConfig",
")",
"*",
"IDP",
"{",
"var",
"idp",
"=",
"new",
"(",
"IDP",
")",
"\n",
"idp",
".",
"config",
"=",
"config",
"\n\n",
"idp",
".",
"cache",
"=",
"cache",
".",
"New",
"(",
"config",
".",
"KeyCacheExpir... | // Create the Identity Provider helper | [
"Create",
"the",
"Identity",
"Provider",
"helper"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L75-L95 |
127,284 | janekolszak/idp | idp.go | refreshCache | func (idp *IDP) refreshCache(key string) {
switch key {
case VerifyPublicKey:
idp.cacheVerificationKey()
return
case ConsentPrivateKey:
idp.cacheConsentKey()
return
default:
// Will get here for client IDs.
// Fine to just let them expire, the next request from that
// client will trigger a refresh
... | go | func (idp *IDP) refreshCache(key string) {
switch key {
case VerifyPublicKey:
idp.cacheVerificationKey()
return
case ConsentPrivateKey:
idp.cacheConsentKey()
return
default:
// Will get here for client IDs.
// Fine to just let them expire, the next request from that
// client will trigger a refresh
... | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"refreshCache",
"(",
"key",
"string",
")",
"{",
"switch",
"key",
"{",
"case",
"VerifyPublicKey",
":",
"idp",
".",
"cacheVerificationKey",
"(",
")",
"\n",
"return",
"\n\n",
"case",
"ConsentPrivateKey",
":",
"idp",
".",
... | // Called when any key expires | [
"Called",
"when",
"any",
"key",
"expires"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L130-L146 |
127,285 | janekolszak/idp | idp.go | downloadVerificationKey | func (idp *IDP) downloadVerificationKey() (*rsa.PublicKey, error) {
jwk, err := idp.hc.JSONWebKeys.GetKey(hoauth2.ConsentChallengeKey, "public")
if err != nil {
return nil, err
}
rsaKey, ok := hjwk.First(jwk.Keys).Key.(*rsa.PublicKey)
if !ok {
return nil, ErrorBadPublicKey
}
return rsaKey, nil
} | go | func (idp *IDP) downloadVerificationKey() (*rsa.PublicKey, error) {
jwk, err := idp.hc.JSONWebKeys.GetKey(hoauth2.ConsentChallengeKey, "public")
if err != nil {
return nil, err
}
rsaKey, ok := hjwk.First(jwk.Keys).Key.(*rsa.PublicKey)
if !ok {
return nil, ErrorBadPublicKey
}
return rsaKey, nil
} | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"downloadVerificationKey",
"(",
")",
"(",
"*",
"rsa",
".",
"PublicKey",
",",
"error",
")",
"{",
"jwk",
",",
"err",
":=",
"idp",
".",
"hc",
".",
"JSONWebKeys",
".",
"GetKey",
"(",
"hoauth2",
".",
"ConsentChallengeKey... | // Downloads the hydra's public key | [
"Downloads",
"the",
"hydra",
"s",
"public",
"key"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L149-L162 |
127,286 | janekolszak/idp | idp.go | downloadConsentKey | func (idp *IDP) downloadConsentKey() (*rsa.PrivateKey, error) {
jwk, err := idp.hc.JSONWebKeys.GetKey(hoauth2.ConsentEndpointKey, "private")
if err != nil {
return nil, err
}
rsaKey, ok := hjwk.First(jwk.Keys).Key.(*rsa.PrivateKey)
if !ok {
return nil, ErrorBadPrivateKey
}
return rsaKey, nil
} | go | func (idp *IDP) downloadConsentKey() (*rsa.PrivateKey, error) {
jwk, err := idp.hc.JSONWebKeys.GetKey(hoauth2.ConsentEndpointKey, "private")
if err != nil {
return nil, err
}
rsaKey, ok := hjwk.First(jwk.Keys).Key.(*rsa.PrivateKey)
if !ok {
return nil, ErrorBadPrivateKey
}
return rsaKey, nil
} | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"downloadConsentKey",
"(",
")",
"(",
"*",
"rsa",
".",
"PrivateKey",
",",
"error",
")",
"{",
"jwk",
",",
"err",
":=",
"idp",
".",
"hc",
".",
"JSONWebKeys",
".",
"GetKey",
"(",
"hoauth2",
".",
"ConsentEndpointKey",
... | // Downloads the private key used for signing the consent | [
"Downloads",
"the",
"private",
"key",
"used",
"for",
"signing",
"the",
"consent"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L165-L177 |
127,287 | janekolszak/idp | idp.go | Connect | func (idp *IDP) Connect(verifyTLS bool) error {
var err error
if verifyTLS {
idp.hc, err = hydra.Connect(
hydra.ClientID(idp.config.ClientID),
hydra.ClientSecret(idp.config.ClientSecret),
hydra.ClusterURL(idp.config.ClusterURL),
)
} else {
idp.hc, err = hydra.Connect(
hydra.ClientID(idp.config.Clie... | go | func (idp *IDP) Connect(verifyTLS bool) error {
var err error
if verifyTLS {
idp.hc, err = hydra.Connect(
hydra.ClientID(idp.config.ClientID),
hydra.ClientSecret(idp.config.ClientSecret),
hydra.ClusterURL(idp.config.ClusterURL),
)
} else {
idp.hc, err = hydra.Connect(
hydra.ClientID(idp.config.Clie... | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"Connect",
"(",
"verifyTLS",
"bool",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"verifyTLS",
"{",
"idp",
".",
"hc",
",",
"err",
"=",
"hydra",
".",
"Connect",
"(",
"hydra",
".",
"ClientID",
"(",
"idp",... | // Connect to Hydra | [
"Connect",
"to",
"Hydra"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L180-L212 |
127,288 | janekolszak/idp | idp.go | getChallengeToken | func (idp *IDP) getChallengeToken(challengeString string) (*jwt.Token, error) {
token, err := jwt.Parse(challengeString, func(token *jwt.Token) (interface{}, error) {
_, ok := token.Method.(*jwt.SigningMethodRSA)
if !ok {
return nil, ErrorBadSigningMethod
}
return idp.getVerificationKey()
})
if err != n... | go | func (idp *IDP) getChallengeToken(challengeString string) (*jwt.Token, error) {
token, err := jwt.Parse(challengeString, func(token *jwt.Token) (interface{}, error) {
_, ok := token.Method.(*jwt.SigningMethodRSA)
if !ok {
return nil, ErrorBadSigningMethod
}
return idp.getVerificationKey()
})
if err != n... | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"getChallengeToken",
"(",
"challengeString",
"string",
")",
"(",
"*",
"jwt",
".",
"Token",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"jwt",
".",
"Parse",
"(",
"challengeString",
",",
"func",
"(",
"token",
... | // Parse and verify the challenge JWT | [
"Parse",
"and",
"verify",
"the",
"challenge",
"JWT"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L215-L234 |
127,289 | janekolszak/idp | idp.go | NewChallenge | func (idp *IDP) NewChallenge(ctx context.Context, r *http.Request, user string) (challenge *Challenge, err error) {
tokenStr := r.FormValue("challenge")
if tokenStr == "" {
// No challenge token
err = ErrorBadRequest
return
}
token, err := idp.getChallengeToken(tokenStr)
if err != nil {
// Most probably, ... | go | func (idp *IDP) NewChallenge(ctx context.Context, r *http.Request, user string) (challenge *Challenge, err error) {
tokenStr := r.FormValue("challenge")
if tokenStr == "" {
// No challenge token
err = ErrorBadRequest
return
}
token, err := idp.getChallengeToken(tokenStr)
if err != nil {
// Most probably, ... | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"NewChallenge",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
",",
"user",
"string",
")",
"(",
"challenge",
"*",
"Challenge",
",",
"err",
"error",
")",
"{",
"tokenStr",
":=",
"r",
... | // Create a new Challenge. The request will contain all the necessary information from Hydra, passed in the URL. | [
"Create",
"a",
"new",
"Challenge",
".",
"The",
"request",
"will",
"contain",
"all",
"the",
"necessary",
"information",
"from",
"Hydra",
"passed",
"in",
"the",
"URL",
"."
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L290-L331 |
127,290 | janekolszak/idp | idp.go | GetChallenge | func (idp *IDP) GetChallenge(r *http.Request) (*Challenge, error) {
session, err := idp.config.ChallengeStore.Get(r, SessionCookieName)
if err != nil {
return nil, err
}
challenge, ok := session.Values[SessionCookieName].(*Challenge)
if !ok {
return nil, ErrorBadChallengeCookie
}
if challenge.Expires.Befor... | go | func (idp *IDP) GetChallenge(r *http.Request) (*Challenge, error) {
session, err := idp.config.ChallengeStore.Get(r, SessionCookieName)
if err != nil {
return nil, err
}
challenge, ok := session.Values[SessionCookieName].(*Challenge)
if !ok {
return nil, ErrorBadChallengeCookie
}
if challenge.Expires.Befor... | [
"func",
"(",
"idp",
"*",
"IDP",
")",
"GetChallenge",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"Challenge",
",",
"error",
")",
"{",
"session",
",",
"err",
":=",
"idp",
".",
"config",
".",
"ChallengeStore",
".",
"Get",
"(",
"r",
",",
"... | // Get the Challenge from a cookie, using Gorilla sessions | [
"Get",
"the",
"Challenge",
"from",
"a",
"cookie",
"using",
"Gorilla",
"sessions"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/idp.go#L334-L352 |
127,291 | janekolszak/idp | challenge.go | Save | func (c *Challenge) Save(w http.ResponseWriter, r *http.Request) error {
session, err := c.idp.config.ChallengeStore.New(r, SessionCookieName)
if err != nil {
return err
}
session.Options = c.idp.createChallengeCookieOptions
session.Values[SessionCookieName] = c
return c.idp.config.ChallengeStore.Save(r, w, s... | go | func (c *Challenge) Save(w http.ResponseWriter, r *http.Request) error {
session, err := c.idp.config.ChallengeStore.New(r, SessionCookieName)
if err != nil {
return err
}
session.Options = c.idp.createChallengeCookieOptions
session.Values[SessionCookieName] = c
return c.idp.config.ChallengeStore.Save(r, w, s... | [
"func",
"(",
"c",
"*",
"Challenge",
")",
"Save",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"session",
",",
"err",
":=",
"c",
".",
"idp",
".",
"config",
".",
"ChallengeStore",
".",
"New",
"(",... | // Saves the Challenge to it's session store | [
"Saves",
"the",
"Challenge",
"to",
"it",
"s",
"session",
"store"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/challenge.go#L46-L56 |
127,292 | janekolszak/idp | challenge.go | Delete | func (c *Challenge) Delete(w http.ResponseWriter, r *http.Request) error {
session, err := c.idp.config.ChallengeStore.Get(r, SessionCookieName)
if err != nil {
return err
}
session.Options = c.idp.deleteChallengeCookieOptions
return c.idp.config.ChallengeStore.Save(r, w, session)
} | go | func (c *Challenge) Delete(w http.ResponseWriter, r *http.Request) error {
session, err := c.idp.config.ChallengeStore.Get(r, SessionCookieName)
if err != nil {
return err
}
session.Options = c.idp.deleteChallengeCookieOptions
return c.idp.config.ChallengeStore.Save(r, w, session)
} | [
"func",
"(",
"c",
"*",
"Challenge",
")",
"Delete",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"session",
",",
"err",
":=",
"c",
".",
"idp",
".",
"config",
".",
"ChallengeStore",
".",
"Get",
"(... | // Deletes the challenge from the store | [
"Deletes",
"the",
"challenge",
"from",
"the",
"store"
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/challenge.go#L72-L80 |
127,293 | janekolszak/idp | challenge.go | RefuseAccess | func (c *Challenge) RefuseAccess(w http.ResponseWriter, r *http.Request) error {
err := c.Delete(w, r)
if err != nil {
return err
}
http.Redirect(w, r, c.Redirect+"&consent=false", http.StatusFound)
return nil
} | go | func (c *Challenge) RefuseAccess(w http.ResponseWriter, r *http.Request) error {
err := c.Delete(w, r)
if err != nil {
return err
}
http.Redirect(w, r, c.Redirect+"&consent=false", http.StatusFound)
return nil
} | [
"func",
"(",
"c",
"*",
"Challenge",
")",
"RefuseAccess",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"err",
":=",
"c",
".",
"Delete",
"(",
"w",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // User refused access to requested scopes, forward the desicion to Hydra via redirection. | [
"User",
"refused",
"access",
"to",
"requested",
"scopes",
"forward",
"the",
"desicion",
"to",
"Hydra",
"via",
"redirection",
"."
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/challenge.go#L83-L92 |
127,294 | janekolszak/idp | challenge.go | GrantAccessToAll | func (c *Challenge) GrantAccessToAll(w http.ResponseWriter, r *http.Request) error {
now := time.Now()
token := jwt.New(jwt.SigningMethodRS256)
claims := token.Claims.(jwt.MapClaims)
claims["aud"] = c.Client.GetID()
claims["exp"] = now.Add(time.Minute * 4).Unix()
claims["iat"] = now.Unix()
claims["scp"] = c.Sc... | go | func (c *Challenge) GrantAccessToAll(w http.ResponseWriter, r *http.Request) error {
now := time.Now()
token := jwt.New(jwt.SigningMethodRS256)
claims := token.Claims.(jwt.MapClaims)
claims["aud"] = c.Client.GetID()
claims["exp"] = now.Add(time.Minute * 4).Unix()
claims["iat"] = now.Unix()
claims["scp"] = c.Sc... | [
"func",
"(",
"c",
"*",
"Challenge",
")",
"GrantAccessToAll",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"token",
":=",
"jwt",
".",
"New",
"("... | // User granted access to requested scopes, forward the desicion to Hydra via redirection. | [
"User",
"granted",
"access",
"to",
"requested",
"scopes",
"forward",
"the",
"desicion",
"to",
"Hydra",
"via",
"redirection",
"."
] | a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e | https://github.com/janekolszak/idp/blob/a4ef1ea49381cd05f4fe96700d2399cd5a51ab1e/challenge.go#L95-L134 |
127,295 | gorilla/css | scanner/scanner.go | emitToken | func (s *Scanner) emitToken(t tokenType, v string) *Token {
token := &Token{t, v, s.row, s.col}
s.updatePosition(v)
return token
} | go | func (s *Scanner) emitToken(t tokenType, v string) *Token {
token := &Token{t, v, s.row, s.col}
s.updatePosition(v)
return token
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"emitToken",
"(",
"t",
"tokenType",
",",
"v",
"string",
")",
"*",
"Token",
"{",
"token",
":=",
"&",
"Token",
"{",
"t",
",",
"v",
",",
"s",
".",
"row",
",",
"s",
".",
"col",
"}",
"\n",
"s",
".",
"updatePo... | // emitToken returns a Token for the string v and updates the scanner position. | [
"emitToken",
"returns",
"a",
"Token",
"for",
"the",
"string",
"v",
"and",
"updates",
"the",
"scanner",
"position",
"."
] | c1a14c1cca8927b0aea71ee7a92add9bb4525a01 | https://github.com/gorilla/css/blob/c1a14c1cca8927b0aea71ee7a92add9bb4525a01/scanner/scanner.go#L333-L337 |
127,296 | gorilla/css | scanner/scanner.go | emitSimple | func (s *Scanner) emitSimple(t tokenType, v string) *Token {
token := &Token{t, v, s.row, s.col}
s.col += len(v)
s.pos += len(v)
return token
} | go | func (s *Scanner) emitSimple(t tokenType, v string) *Token {
token := &Token{t, v, s.row, s.col}
s.col += len(v)
s.pos += len(v)
return token
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"emitSimple",
"(",
"t",
"tokenType",
",",
"v",
"string",
")",
"*",
"Token",
"{",
"token",
":=",
"&",
"Token",
"{",
"t",
",",
"v",
",",
"s",
".",
"row",
",",
"s",
".",
"col",
"}",
"\n",
"s",
".",
"col",
... | // emitSimple returns a Token for the string v and updates the scanner
// position in a simplified manner.
//
// The string is known to have only ASCII characters and to not have a newline. | [
"emitSimple",
"returns",
"a",
"Token",
"for",
"the",
"string",
"v",
"and",
"updates",
"the",
"scanner",
"position",
"in",
"a",
"simplified",
"manner",
".",
"The",
"string",
"is",
"known",
"to",
"have",
"only",
"ASCII",
"characters",
"and",
"to",
"not",
"ha... | c1a14c1cca8927b0aea71ee7a92add9bb4525a01 | https://github.com/gorilla/css/blob/c1a14c1cca8927b0aea71ee7a92add9bb4525a01/scanner/scanner.go#L343-L348 |
127,297 | gorilla/css | scanner/scanner.go | emitPrefixOrChar | func (s *Scanner) emitPrefixOrChar(t tokenType, prefix string) *Token {
if strings.HasPrefix(s.input[s.pos:], prefix) {
return s.emitSimple(t, prefix)
}
return s.emitSimple(TokenChar, string(prefix[0]))
} | go | func (s *Scanner) emitPrefixOrChar(t tokenType, prefix string) *Token {
if strings.HasPrefix(s.input[s.pos:], prefix) {
return s.emitSimple(t, prefix)
}
return s.emitSimple(TokenChar, string(prefix[0]))
} | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"emitPrefixOrChar",
"(",
"t",
"tokenType",
",",
"prefix",
"string",
")",
"*",
"Token",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"s",
".",
"input",
"[",
"s",
".",
"pos",
":",
"]",
",",
"prefix",
")",
"{",
... | // emitPrefixOrChar returns a Token for type t if the current position
// matches the given prefix. Otherwise it returns a Char token using the
// first character from the prefix.
//
// The prefix is known to have only ASCII characters and to not have a newline. | [
"emitPrefixOrChar",
"returns",
"a",
"Token",
"for",
"type",
"t",
"if",
"the",
"current",
"position",
"matches",
"the",
"given",
"prefix",
".",
"Otherwise",
"it",
"returns",
"a",
"Char",
"token",
"using",
"the",
"first",
"character",
"from",
"the",
"prefix",
... | c1a14c1cca8927b0aea71ee7a92add9bb4525a01 | https://github.com/gorilla/css/blob/c1a14c1cca8927b0aea71ee7a92add9bb4525a01/scanner/scanner.go#L355-L360 |
127,298 | rsc/qr | coding/qr.go | DataBytes | func (v Version) DataBytes(l Level) int {
vt := &vtab[v]
lev := &vt.level[l]
return vt.bytes - lev.nblock*lev.check
} | go | func (v Version) DataBytes(l Level) int {
vt := &vtab[v]
lev := &vt.level[l]
return vt.bytes - lev.nblock*lev.check
} | [
"func",
"(",
"v",
"Version",
")",
"DataBytes",
"(",
"l",
"Level",
")",
"int",
"{",
"vt",
":=",
"&",
"vtab",
"[",
"v",
"]",
"\n",
"lev",
":=",
"&",
"vt",
".",
"level",
"[",
"l",
"]",
"\n",
"return",
"vt",
".",
"bytes",
"-",
"lev",
".",
"nblock... | // DataBytes returns the number of data bytes that can be
// stored in a QR code with the given version and level. | [
"DataBytes",
"returns",
"the",
"number",
"of",
"data",
"bytes",
"that",
"can",
"be",
"stored",
"in",
"a",
"QR",
"code",
"with",
"the",
"given",
"version",
"and",
"level",
"."
] | ca9a01fc2f9505024045632c50e5e8cd6142fafe | https://github.com/rsc/qr/blob/ca9a01fc2f9505024045632c50e5e8cd6142fafe/coding/qr.go#L45-L49 |
127,299 | rsc/qr | coding/qr.go | NewPlan | func NewPlan(version Version, level Level, mask Mask) (*Plan, error) {
p, err := vplan(version)
if err != nil {
return nil, err
}
if err := fplan(level, mask, p); err != nil {
return nil, err
}
if err := lplan(version, level, p); err != nil {
return nil, err
}
if err := mplan(mask, p); err != nil {
retu... | go | func NewPlan(version Version, level Level, mask Mask) (*Plan, error) {
p, err := vplan(version)
if err != nil {
return nil, err
}
if err := fplan(level, mask, p); err != nil {
return nil, err
}
if err := lplan(version, level, p); err != nil {
return nil, err
}
if err := mplan(mask, p); err != nil {
retu... | [
"func",
"NewPlan",
"(",
"version",
"Version",
",",
"level",
"Level",
",",
"mask",
"Mask",
")",
"(",
"*",
"Plan",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"vplan",
"(",
"version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",... | // NewPlan returns a Plan for a QR code with the given
// version, level, and mask. | [
"NewPlan",
"returns",
"a",
"Plan",
"for",
"a",
"QR",
"code",
"with",
"the",
"given",
"version",
"level",
"and",
"mask",
"."
] | ca9a01fc2f9505024045632c50e5e8cd6142fafe | https://github.com/rsc/qr/blob/ca9a01fc2f9505024045632c50e5e8cd6142fafe/coding/qr.go#L362-L377 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.