options.go

package nsqd

import (
    "crypto/md5"
    "crypto/tls"
    "hash/crc32"
    "io"
    "log"
    "os"
    "time"
)

type Options struct {
    // basic options
    ID                       int64         `flag:"worker-id" cfg:"id"`
    Verbose                  bool          `flag:"verbose"`
    TCPAddress               string        `flag:"tcp-address"`
    HTTPAddress              string        `flag:"http-address"`
    HTTPSAddress             string        `flag:"https-address"`
    BroadcastAddress         string        `flag:"broadcast-address"`
    NSQLookupdTCPAddresses   []string      `flag:"lookupd-tcp-address" cfg:"nsqlookupd_tcp_addresses"`
    AuthHTTPAddresses        []string      `flag:"auth-http-address" cfg:"auth_http_addresses"`
    HTTPClientConnectTimeout time.Duration `flag:"http-client-connect-timeout" cfg:"http_client_connect_timeout"`
    HTTPClientRequestTimeout time.Duration `flag:"http-client-request-timeout" cfg:"http_client_request_timeout"`

    // diskqueue options
    DataPath        string        `flag:"data-path"`
    MemQueueSize    int64         `flag:"mem-queue-size"`
    MaxBytesPerFile int64         `flag:"max-bytes-per-file"`
    SyncEvery       int64         `flag:"sync-every"`
    SyncTimeout     time.Duration `flag:"sync-timeout"`

    QueueScanInterval        time.Duration
    QueueScanRefreshInterval time.Duration
    QueueScanSelectionCount  int
    QueueScanWorkerPoolMax   int
    QueueScanDirtyPercent    float64

    // msg and command options
    MsgTimeout    time.Duration `flag:"msg-timeout" arg:"1ms"`
    MaxMsgTimeout time.Duration `flag:"max-msg-timeout"`
    MaxMsgSize    int64         `flag:"max-msg-size" deprecated:"max-message-size" cfg:"max_msg_size"`
    MaxBodySize   int64         `flag:"max-body-size"`
    MaxReqTimeout time.Duration `flag:"max-req-timeout"`
    ClientTimeout time.Duration

    // client overridable configuration options
    MaxHeartbeatInterval   time.Duration `flag:"max-heartbeat-interval"`
    MaxRdyCount            int64         `flag:"max-rdy-count"`
    MaxOutputBufferSize    int64         `flag:"max-output-buffer-size"`
    MaxOutputBufferTimeout time.Duration `flag:"max-output-buffer-timeout"`

    // statsd integration
    StatsdAddress  string        `flag:"statsd-address"`
    StatsdPrefix   string        `flag:"statsd-prefix"`
    StatsdInterval time.Duration `flag:"statsd-interval" arg:"1s"`
    StatsdMemStats bool          `flag:"statsd-mem-stats"`

    // e2e message latency
    E2EProcessingLatencyWindowTime  time.Duration `flag:"e2e-processing-latency-window-time"`
    E2EProcessingLatencyPercentiles []float64     `flag:"e2e-processing-latency-percentile" cfg:"e2e_processing_latency_percentiles"`

    // TLS config
    TLSCert             string `flag:"tls-cert"`
    TLSKey              string `flag:"tls-key"`
    TLSClientAuthPolicy string `flag:"tls-client-auth-policy"`
    TLSRootCAFile       string `flag:"tls-root-ca-file"`
    TLSRequired         int    `flag:"tls-required"`
    TLSMinVersion       uint16 `flag:"tls-min-version"`

    // compression
    DeflateEnabled  bool `flag:"deflate"`
    MaxDeflateLevel int  `flag:"max-deflate-level"`
    SnappyEnabled   bool `flag:"snappy"`

    Logger Logger
}

func NewOptions() *Options {
    hostname, err := os.Hostname()
    if err != nil {
        log.Fatal(err)
    }

    h := md5.New()
    io.WriteString(h, hostname)
    defaultID := int64(crc32.ChecksumIEEE(h.Sum(nil)) % 1024)

    return &Options{
        ID: defaultID,

        TCPAddress:       "0.0.0.0:4150",
        HTTPAddress:      "0.0.0.0:4151",
        HTTPSAddress:     "0.0.0.0:4152",
        BroadcastAddress: hostname,

        NSQLookupdTCPAddresses: make([]string, 0),
        AuthHTTPAddresses:      make([]string, 0),

        HTTPClientConnectTimeout: 2 * time.Second,
        HTTPClientRequestTimeout: 5 * time.Second,

        MemQueueSize:    10000,
        MaxBytesPerFile: 100 * 1024 * 1024,
        SyncEvery:       2500,
        SyncTimeout:     2 * time.Second,

        QueueScanInterval:        100 * time.Millisecond,
        QueueScanRefreshInterval: 5 * time.Second,
        QueueScanSelectionCount:  20,
        QueueScanWorkerPoolMax:   4,
        QueueScanDirtyPercent:    0.25,

        MsgTimeout:    60 * time.Second,
        MaxMsgTimeout: 15 * time.Minute,
        MaxMsgSize:    1024 * 1024,
        MaxBodySize:   5 * 1024 * 1024,
        MaxReqTimeout: 1 * time.Hour,
        ClientTimeout: 60 * time.Second,

        MaxHeartbeatInterval:   60 * time.Second,
        MaxRdyCount:            2500,
        MaxOutputBufferSize:    64 * 1024,
        MaxOutputBufferTimeout: 1 * time.Second,

        StatsdPrefix:   "nsq.%s",
        StatsdInterval: 60 * time.Second,
        StatsdMemStats: true,

        E2EProcessingLatencyWindowTime: time.Duration(10 * time.Minute),

        DeflateEnabled:  true,
        MaxDeflateLevel: 6,
        SnappyEnabled:   true,

        TLSMinVersion: tls.VersionTLS10,

        Logger: log.New(os.Stderr, "[nsqd] ", log.Ldate|log.Ltime|log.Lmicroseconds),
    }
}
				
时间: 2024-08-25 12:46:27

options.go的相关文章

【oracle】oracledba4 when you need to change storage options

In which scenarios would you rebuild an index? (Choose all that a pply.) A. when you need to disable the index usage B. when you need to change storage options C. when you need to enable index monitoring D. when you need to move the index to another 

Kickstart Options

The following options can be placed in a kickstart file. If you prefer to use a graphical interface for creating your kickstart file, use the Kickstart Configurator application. Refer to Chapter 29, Kickstart Configurator for details. Note If the opt

Allow Pin Swapping Using these Methods options

Frm:http://techdocs.altium.com/display/ADOH/Pin,+Pair+and+Part+Swapping#Pin,PairandPartSwapping-SwapManagerDialog Controlling How the Swaps are Performed on the Schematic In the PCB editor pin, pair and part swaps are performed by exchanging nets on

CORS 中的POST and OPTIONS 请求

var req = new XMLHttpRequest(); req.open('post', 'http://127.0.0.1:3001/user', true); req.setRequestHeader('Content-Type', 'application/json'); req.send('{"name":"tobi","species":"ferret"}'); 此Ajax 跨域访问post 请求,但是在服务

Streams Studio配置Build options

Defining build options You can change the build options of the internal builder for building an SPL application using the InfoSphere® Streams Studio. About this task When you create a stand-alone build configuration or a distributed build configurati

EasyUI实战篇之datagrid:如何重新设置datagrid所配置的属性(options)并重新查询列表(relaod)

http://www.stepday.com/topic/?873 今天在使用EasyUI的datagrid列表组件想实现一个列表的展现,且列表上方有搜索条件,初始化的时候我是这样配置的: view sourceprint? 1.<table id="tBaoXiuList" title="" class="easyui-datagrid" style="width: 723px; height: auto" url=&

win7主机与linux虚拟机共享方法之右键添加Sharing Options

在win7上建了个linux虚拟机,虚拟机中装好samba. 如果对着文件夹进行右键操作,没发现Sharing Options,再执行下面的安装: sudo apt-get install nautilus-share 重启虚拟机后即可生效.

JSHint Options 翻译

Enforcing options When set to true, these options will make JSHint produce more warnings about your code. bitwise This option prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others. Bitwise operators are very rare in JavaScript pro

UIViewController新方法的使用(transitionFromViewController:toViewController:duration:options:animations:completion:)

iOS5中,UIViewController新添加了几个方法: - (void)addChildViewController:(UIViewController *)childController NS_AVAILABLE_IOS(5_0); - (void) removeFromParentViewController NS_AVAILABLE_IOS(5_0); - (void)transitionFromViewController:(UIViewController *)fromView

Spring boot处理OPTIONS请求

一.现象从fetch说起,用fetch构造一个POST请求. 1 fetch('http://127.0.0.1:8000/api/login', { 2 method: "POST", 3 headers: ({ 4 'Content-Type': 'application/x-www-form-urlencoded' 5 }), 6 body: "name=" + name + "&password=" + pwd 7 }).then