1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
dev-tools
filebeat
generator
heartbeat
libbeat
_meta
beat
cfgfile
common
dashboards
docs
logp
ml-importer
mock
monitoring
outputs
codecs
console
elasticsearch
fileout
kafka
logstash
mode
outil
redis
transport
codec.go
outputs.go
plugin.go
tls.go
tls_test.go
values.go
paths
plugin
processors
publisher
scripts
service
setup/kibana
tests
.gitignore
Dockerfile
Makefile
README.md
docker-compose.yml
libbeat.go
libbeat.template-es6x.json
libbeat_test.go
metricbeat
packetbeat
script
testing/environments
vendor
winlogbeat
.appveyor.yml
.editorconfig
.gitattributes
.gitignore
.go-version
.travis.yml
CHANGELOG.asciidoc
CONTRIBUTING.md
Dockerfile
LICENSE
Makefile
NOTICE
README.md
Vagrantfile
codecov.yml
glide.yaml
克隆/下载
values.go 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
package outputs
import "github.com/elastic/beats/libbeat/common"
// Values is a recursive key/value store for use by output plugins and publisher
// pipeline to share context-dependent values.
type Values struct {
parent *Values
key, value interface{}
}
// ValueWith creates new key/value store shadowing potentially old keys.
func ValueWith(parent *Values, key interface{}, value interface{}) *Values {
return &Values{
parent: parent,
key: key,
value: value,
}
}
// Append creates new key/value store from existing store by adding a new
// key/value pair potentially shadowing an already present key/value pair.
func (v *Values) Append(key, value interface{}) *Values {
if v.IsEmpty() {
return ValueWith(nil, key, value)
}
return ValueWith(v, key, value)
}
// IsEmpty returns true if key/value store is empty.
func (v *Values) IsEmpty() bool {
return v == nil || (v.parent == nil && v.key == nil && v.value == nil)
}
// Get retrieves a value for the given key.
func (v *Values) Get(key interface{}) (interface{}, bool) {
if v == nil {
return nil, false
}
if v.key == key {
return v.value, true
}
return v.parent.Get(key)
}
// standard outputs values utilities
type keyMetadata int
func ValuesWithMetadata(parent *Values, meta common.MapStr) *Values {
return parent.Append(keyMetadata(0), meta)
}
func GetMetadata(v *Values) common.MapStr {
value, ok := v.Get(keyMetadata(0))
if !ok {
return nil
}
if m, ok := value.(common.MapStr); ok {
return m
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.6.15

搜索帮助