码迷,mamicode.com
首页 > 其他好文 > 详细

nsqadmin

时间:2018-03-29 21:21:27      阅读:385      评论:0      收藏:0      [点我收藏+]

标签:ttl   保存   class   val   etop   atom   interface   min   方法   

nsqadmin 结构体定义

type Options struct {
    LogLevel  string `flag:"log-level"`
    LogPrefix string `flag:"log-prefix"`
    Verbose   bool   `flag:"verbose"` // for backwards compatibility
    Logger    Logger
    logLevel  lg.LogLevel // private, not really an option

    HTTPAddress string `flag:"http-address"`

    GraphiteURL   string `flag:"graphite-url"`
    ProxyGraphite bool   `flag:"proxy-graphite"`

    StatsdPrefix        string `flag:"statsd-prefix"`
    StatsdCounterFormat string `flag:"statsd-counter-format"`
    StatsdGaugeFormat   string `flag:"statsd-gauge-format"`

    StatsdInterval time.Duration `flag:"statsd-interval"`

    NSQLookupdHTTPAddresses []string `flag:"lookupd-http-address" cfg:"nsqlookupd_http_addresses"`
    NSQDHTTPAddresses       []string `flag:"nsqd-http-address" cfg:"nsqd_http_addresses"`

    HTTPClientConnectTimeout time.Duration `flag:"http-client-connect-timeout"`
    HTTPClientRequestTimeout time.Duration `flag:"http-client-request-timeout"`

    HTTPClientTLSInsecureSkipVerify bool   `flag:"http-client-tls-insecure-skip-verify"`
    HTTPClientTLSRootCAFile         string `flag:"http-client-tls-root-ca-file"`
    HTTPClientTLSCert               string `flag:"http-client-tls-cert"`
    HTTPClientTLSKey                string `flag:"http-client-tls-key"`

    AllowConfigFromCIDR string `flag:"allow-config-from-cidr"`

    NotificationHTTPEndpoint string `flag:"notification-http-endpoint"`

    AclHttpHeader string   `flag:"acl-http-header"`
    AdminUsers    []string `flag:"admin-user" cfg:"admin_users"`
}

Options 只有一个 New 方法, 就是创建一个 NSQAdmin 对象:

func New(opts *Options) *NSQAdmin {}
type NSQAdmin struct {
    sync.RWMutex
    opts                atomic.Value // interface 类型,实际保存的是 *Options
    httpListener        net.Listener
    waitGroup           util.WaitGroupWrapper
    notifications       chan *AdminAction
    graphiteURL         *url.URL
    httpClientTLSConfig *tls.Config
}

再看看 NSQAdmin 提供了哪些方法:

// 读取 ops 的值,这里用的 atomic 来保证同步操作
func (n *NSQAdmin) getOpts() *Options {}

// 存储 ops 的值
func (n *NSQAdmin) swapOpts(opts *Options) {}

// 返回服务器地址,即: net.Listener.Addr()
func (n *NSQAdmin) RealHTTPAddr() *net.TCPAddr {}

// 从 channel 中读取消息,转换成 json, 然后发送到 nsq 节点
func (n *NSQAdmin) handleAdminActions() {}

// 退出清理操作
// 关闭 http 监听, 关闭 channel
func (n *NSQAdmin) Exit() {}

// 监听端口
func (n *NSQAdmin) Main() {}

nsqadmin

标签:ttl   保存   class   val   etop   atom   interface   min   方法   

原文地址:https://www.cnblogs.com/baisu/p/8672108.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!