• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang flag.DurationVar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中flag.DurationVar函数的典型用法代码示例。如果您正苦于以下问题:Golang DurationVar函数的具体用法?Golang DurationVar怎么用?Golang DurationVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了DurationVar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	flag.BoolVar(&versionFlag, "version", false, "Print the version number and exit.")
	flag.BoolVar(&versionFlag, "V", false, "Print the version number and exit (shorthand).")

	flag.StringVar(&verboseFlag, "verbose", "", "Display debug information: choose between text or JSON.")
	flag.StringVar(&verboseFlag, "v", "", "Display debug information: choose between text or JSON (shorthand).")

	hostname, _ := os.Hostname()
	flag.StringVar(&prefixFlag, "prefix", hostname, "Change series name prefix.")
	flag.StringVar(&prefixFlag, "P", hostname, "Change series name prefix (shorthand).")

	flag.StringVar(&hostFlag, "host", "localhost:8086", "Connect to host.")
	flag.StringVar(&hostFlag, "h", "localhost:8086", "Connect to host (shorthand).")
	flag.StringVar(&usernameFlag, "username", "root", "User for login.")
	flag.StringVar(&usernameFlag, "u", "root", "User for login (shorthand).")
	flag.StringVar(&passwordFlag, "password", "root", "Password to use when connecting to server.")
	flag.StringVar(&passwordFlag, "p", "root", "Password to use when connecting to server (shorthand).")
	flag.StringVar(&databaseFlag, "database", "", "Name of the database to use.")
	flag.StringVar(&databaseFlag, "d", "", "Name of the database to use (shorthand).")

	flag.StringVar(&collectFlag, "collect", "cpus,mem,swap,uptime,load,network,disks", "Chose which data to collect.")
	flag.StringVar(&collectFlag, "c", "cpus,mem,swap,uptime,load,network,disks", "Chose which data to collect (shorthand).")

	flag.BoolVar(&daemonFlag, "daemon", false, "Run in daemon mode.")
	flag.BoolVar(&daemonFlag, "D", false, "Run in daemon mode (shorthand).")
	flag.DurationVar(&daemonIntervalFlag, "interval", time.Second, "With daemon mode, change time between checks.")
	flag.DurationVar(&daemonIntervalFlag, "i", time.Second, "With daemon mode, change time between checks (shorthand).")
}
开发者ID:joukou-forks,项目名称:sysinfo_influxdb,代码行数:28,代码来源:main.go


示例2: parseArgs

func parseArgs() {
	// set options
	flag.DurationVar(&option.interval, "interval",
		time.Second, "Measurement interval")
	flag.BoolVar(&option.no_interval_backoff, "no-interval-backoff",
		false, "Disable interval backoff")
	flag.DurationVar(&option.timeout, "timeout",
		time.Second*0, "Measurement timeout")
	flag.DurationVar(&option.start_delay, "start-delay",
		time.Second*0, "Wait time before measurement")
	flag.StringVar(&option.output, "output",
		"-", "Output file name")
	flag.BoolVar(&option.no_cpu, "no-cpu",
		false, "Do not record CPU usage")
	flag.BoolVar(&option.no_disk, "no-disk",
		false, "Do not record disk usage")
	flag.BoolVar(&option.no_net, "no-net",
		false, "Do not record net usage")
	flag.BoolVar(&option.debug, "debug",
		false, "Enable debug mode")
	flag.BoolVar(&option.listDevices, "list-devices",
		false, "List devices and exits")
	flag.StringVar(&option.disks, "disks",
		"", "Disk devices to be monitored")
	flag.StringVar(&option.player_bin, "player-bin",
		"", "Run perfmonger-player to show JSON output")

	flag.Parse()

	if option.player_bin == "" && terminal.IsTerminal(int(os.Stdout.Fd())) &&
		option.output == "-" {
		fmt.Fprintf(os.Stderr, "[recording to data.pgr]\n")
		option.output = "data.pgr"
	}

	if option.disks == "" {
		option.targetDisks = nil
	} else {
		option.targetDisks = new(map[string]bool)
		*option.targetDisks = make(map[string]bool)
		for _, dev := range strings.Split(option.disks, ",") {
			(*option.targetDisks)[dev] = true
		}
	}

	if option.debug {
		os.Stderr.WriteString(
			fmt.Sprintf(
				`== option
  - output   : %s
  - interval : %s
  - debug    : %t
  - remainings: %s
`,
				option.output,
				option.interval.String(),
				option.debug,
				fmt.Sprint(flag.Args())))
	}
}
开发者ID:pazjacket,项目名称:hayamiz-_-perfmonger,代码行数:60,代码来源:perfmonger-recorder.go


示例3: init

func init() {
	flag.BoolVar(&versionFlag, "version", false, "Print the version number and exit.")
	flag.BoolVar(&versionFlag, "V", false, "Print the version number and exit (shorthand).")

	flag.BoolVar(&verboseFlag, "verbose", false, "Display debug information: choose between text or JSON.")
	flag.BoolVar(&verboseFlag, "v", false, "Display debug information: choose between text or JSON (shorthand).")

	flag.BoolVar(&sslFlag, "ssl", false, "Enable SSL/TLS encryption.")
	flag.BoolVar(&sslFlag, "S", false, "Enable SSL/TLS encryption (shorthand).")
	flag.StringVar(&hostFlag, "host", "localhost:8086", "Connect to host.")
	flag.StringVar(&hostFlag, "h", "localhost:8086", "Connect to host (shorthand).")
	flag.StringVar(&usernameFlag, "username", "root", "User for login.")
	flag.StringVar(&usernameFlag, "u", "root", "User for login (shorthand).")
	flag.StringVar(&passwordFlag, "password", "root", "Password to use when connecting to server.")
	flag.StringVar(&passwordFlag, "p", "root", "Password to use when connecting to server (shorthand).")
	flag.StringVar(&secretFlag, "secret", "", "Absolute path to password file (shorthand). '-p' is ignored if specifed.")
	flag.StringVar(&secretFlag, "s", "", "Absolute path to password file. '-p' is ignored if specifed.")
	flag.StringVar(&databaseFlag, "database", "", "Name of the database to use.")
	flag.StringVar(&databaseFlag, "d", "", "Name of the database to use (shorthand).")
	flag.StringVar(&retentionPolicyFlag, "retentionpolicy", "", "Name of the retention policy to use.")
	flag.StringVar(&retentionPolicyFlag, "rp", "", "Name of the retention policy to use (shorthand).")

	flag.StringVar(&collectFlag, "collect", "cpu,cpus,mem,swap,uptime,load,network,disks,mounts", "Chose which data to collect.")
	flag.StringVar(&collectFlag, "c", "cpu,cpus,mem,swap,uptime,load,network,disks,mounts", "Chose which data to collect (shorthand).")

	flag.BoolVar(&daemonFlag, "daemon", false, "Run in daemon mode.")
	flag.BoolVar(&daemonFlag, "D", false, "Run in daemon mode (shorthand).")
	flag.DurationVar(&daemonIntervalFlag, "interval", time.Second, "With daemon mode, change time between checks.")
	flag.DurationVar(&daemonIntervalFlag, "i", time.Second, "With daemon mode, change time between checks (shorthand).")
	flag.DurationVar(&daemonConsistencyFlag, "consistency", time.Second, "With custom interval, duration to bring back collected values for data consistency (0s to disable).")
	flag.DurationVar(&daemonConsistencyFlag, "C", time.Second, "With daemon mode, duration to bring back collected values for data consistency (shorthand).")

	flag.StringVar(&pidFile, "pidfile", "", "the pid file")
}
开发者ID:jmptrader,项目名称:sysinfo_influxdb,代码行数:34,代码来源:main.go


示例4: init

func init() {
	defaultDelay := time.Duration(1500 * time.Millisecond)
	flag.DurationVar(&delayFlag, "d", defaultDelay, "")
	flag.DurationVar(&delayFlag, "delay", defaultDelay, "")

	flag.BoolVar(&kernelFlag, "k", false, "")
	flag.BoolVar(&kernelFlag, "kernel", false, "")

	flag.StringVar(&pidsFlag, "p", "", "")
	flag.StringVar(&pidsFlag, "pids", "", "")

	defaultSort := CPUPercentColumn.Title
	flag.StringVar(&sortFlag, "s", defaultSort, "")
	flag.StringVar(&sortFlag, "sort", defaultSort, "")

	flag.BoolVar(&treeFlag, "t", false, "")
	flag.BoolVar(&treeFlag, "tree", false, "")

	flag.StringVar(&usersFlag, "u", "", "")
	flag.StringVar(&usersFlag, "users", "", "")

	flag.BoolVar(&verboseFlag, "verbose", false, "")

	flag.Usage = func() {
		fmt.Fprint(os.Stdout, usage)
	}
}
开发者ID:mayhewj,项目名称:jtop,代码行数:27,代码来源:jtop.go


示例5: main

func main() {
	flag.StringVar(&emailAddr, "email", "[email protected]", "email recipient for notificiations")
	flag.StringVar(&listenAddr, "listen", ":7700", "webserver listen address")
	flag.IntVar(&failLimit, "failLimit", 4, "number failed ping attempts in a row to consider host down")
	flag.DurationVar(&interval, "interval", 5*time.Second, "seconds between each ping")
	flag.DurationVar(&ping.TimeOut, "timeOut", 5*time.Second, "seconds for single ping timeout")
	flag.Parse()

	// read non flag arguments as hosts to start monitoring
	hosts := flag.Args()

	var pool = &pingd.Pool{
		Interval:  interval,
		FailLimit: failLimit,
		Receive:   http.NewReceiverFunc(listenAddr),          // start/stop commands via HTTP
		Notify:    mail.NewNotifierFunc(emailAddr, sendMail), // notify up/down via email
		Load:      std.NewLoaderFunc(hosts),                  // load initial hosts from command line
	}

	pool.Start()

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)

	<-c // Exit on interrupt
}
开发者ID:agilemobiledev,项目名称:pingd,代码行数:26,代码来源:cmd.go


示例6: ClientFromFlag

// Define a new Client via Flags. Note you must call client.Open() before using
// it.
func ClientFromFlag(name string) *Client {
	c := &Client{}
	hostname, _ := os.Hostname()
	flag.StringVar(
		&c.Host,
		name+".host",
		hostname,
		"hostname for ganglia",
	)
	flag.StringVar(
		&c.Spoof,
		name+".spoof",
		"",
		"spoof hostname for ganglia",
	)
	flag.DurationVar(
		&c.TickInterval,
		name+".tick-interval",
		time.Minute,
		"tick interval for ganglia",
	)
	flag.DurationVar(
		&c.Lifetime,
		name+".lifetime",
		time.Hour*24*30, // 30 days
		"metrics lifetime for ganglia",
	)
	addrs.FlagManyVar(
		&c.Addr,
		name+".addrs",
		"udp:127.0.0.1:8649",
		"comma separated list of net:host:port triples of ganglia leaf nodes",
	)
	return c
}
开发者ID:huhaibo,项目名称:go.ganglia,代码行数:37,代码来源:gmetric.go


示例7: parseFlags

func parseFlags() {
	flag.DurationVar(&interval, "i", -1,
		"set execution interval for command, e.g. 45s, 2m, 1h30m, default: 1/10 of timeout")
	flag.DurationVar(&timeout, "t", 1*time.Minute,
		"set execution timeout for command, e.g. 45s, 2m, 1h30m, default: 1m")
	flag.BoolVar(&useSyslog, "s", false, "log via syslog")
	flag.BoolVar(&pipeStderr, "e", true, "pipe stderr to log")
	flag.BoolVar(&pipeStdout, "o", true, "pipe stdout to log")
	flag.BoolVar(&killRunning, "k", false, "kill already running instance of command")
	flag.Parse()

	if flag.NArg() < 1 {
		log.Fatal("FATAL: no command to execute")
	}

	command = flag.Arg(0)

	if interval >= timeout {
		log.Fatal("FATAL: interval >= timeout, no time left for actual command execution")
	}

	if interval == -1 {
		interval = timeout / 10
	}
}
开发者ID:nightlyone,项目名称:periodicnoise,代码行数:25,代码来源:main.go


示例8: parseArguments

func parseArguments() (string, *status_updater.EtcdConnectionParams, *status_updater.KeyUpdaterParameters) {
	var unixSocketPath string
	etcdParams := status_updater.EtcdConnectionParams{}
	keyUpdaterParams := status_updater.KeyUpdaterParameters{}

	// etcd connection params
	flag.StringVar(&etcdParams.Endpoint, "etcd-endpoint", "http://127.0.0.1:4001,http://127.0.0.1:2379", "Coma separated etcd endpoints")
	//
	flag.StringVar(&etcdParams.CertFile, "etcd-cert-file", "", "identify HTTPS client using this SSL certificate file")
	flag.StringVar(&etcdParams.KeyFile, "etcd-key-file", "", "identify HTTPS client using this SSL key file")
	flag.StringVar(&etcdParams.CaFile, "etcd-ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
	flag.StringVar(&etcdParams.Username, "etcd-user", "", "Etcd auth user")
	flag.StringVar(&etcdParams.Password, "etcd-password", "", "Etcd auth password")
	flag.DurationVar(&etcdParams.ConnectionTimeout, "etcd-timeout", time.Second, "etcd connection timeout per request")
	flag.DurationVar(&etcdParams.RequestTimeout, "etcd-request-timeout", 5*time.Second, "etcd requst timeout")

	// Server socket path
	flag.StringVar(&unixSocketPath, "socket", "/tmp/artd-status-updater.sock", "Path to unix socket liten on")

	// Key updater parameters
	flag.StringVar(&keyUpdaterParams.Key, "key", "/artifact-downloader/status", "Key where to push status")
	flag.DurationVar(&keyUpdaterParams.KeyTTL, "key-ttl", 10*time.Second, "TTL for status key")
	flag.DurationVar(&keyUpdaterParams.RetryFreq, "key-retry-freq", 1*time.Second, "Key update retry update freq")
	flag.DurationVar(&keyUpdaterParams.UpdateFreq, "key-update-freq", 5*time.Second, "Key update freq")

	flag.Parse()

	return unixSocketPath, &etcdParams, &keyUpdaterParams
}
开发者ID:code-tool,项目名称:artd-status-updater,代码行数:29,代码来源:main.go


示例9: main

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	flag.IntVar(&cfg.Port, "port", 9033, "port to listen on")
	flag.StringVar(&cfg.DataBasePath, "data", "/tmp/qrpc", "directory in which queue data is stored")
	flag.Uint64Var(&cfg.MaxCacheSize, "cache", 1024*1024, "max. cache size (bytes) before an item is evicted.")
	flag.DurationVar(&cfg.ClusterRequestTimeout, "timeout", 3*time.Second, "cluster request (gossip) timeout.")
	flag.DurationVar(&cfg.ClusterWatchInterval, "interval", time.Second, "cluster watch timer interval.")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [flags] [cluster peer(s) ...]\n", os.Args[0])
		fmt.Fprintln(os.Stderr, "flags:")
		flag.PrintDefaults()
		os.Exit(2)
	}
	flag.Parse()
	cfg.ClusterPeers = flag.Args()

	s := qrpc.NewServer(&cfg)
	errchan := s.Start()

	// Handle SIGINT and SIGTERM.
	sigchan := make(chan os.Signal, 1)
	signal.Notify(sigchan, os.Interrupt, os.Kill)

	select {
	case sig := <-sigchan:
		log.Printf("Signal %s received, shutting down...\n", sig)
		s.Stop()

	case err := <-errchan:
		log.Fatalln(err)
	}
}
开发者ID:kuba--,项目名称:qrpc,代码行数:33,代码来源:qrpc.go


示例10: ParseFlags

func (c *ShuttleConfig) ParseFlags() {
	flag.BoolVar(&c.PrintVersion, "version", false, "Print log-shuttle version.")
	flag.BoolVar(&c.Verbose, "verbose", false, "Enable verbose debug info.")
	flag.BoolVar(&c.SkipHeaders, "skip-headers", false, "Skip the prepending of rfc5424 headers.")
	flag.BoolVar(&c.SkipVerify, "skip-verify", false, "Skip the verification of HTTPS server certificate.")
	flag.StringVar(&c.Prival, "prival", "190", "The primary value of the rfc5424 header.")
	flag.StringVar(&c.Version, "syslog-version", "1", "The version of syslog.")
	flag.StringVar(&c.Procid, "procid", "shuttle", "The procid field for the syslog header.")
	flag.StringVar(&c.Appname, "appname", "", "The app-name field for the syslog header.")
	flag.StringVar(&c.Appname, "logplex-token", "", "Secret logplex token.")
	flag.StringVar(&c.Hostname, "hostname", "shuttle", "The hostname field for the syslog header.")
	flag.StringVar(&c.Msgid, "msgid", "- -", "The msgid field for the syslog header.")
	flag.StringVar(&c.LogsURL, "logs-url", "", "The receiver of the log data.")
	flag.StringVar(&c.StatsAddr, "stats-addr", DEFAULT_STATS_ADDR, "Where to expose stats.")
	flag.StringVar(&c.StatsSource, "stats-source", DEFAULT_STATS_SOURCE, "When emitting stats, add source=<stats-source> to the stats.")
	flag.DurationVar(&c.StatsInterval, "stats-interval", time.Duration(DEFAULT_STATS_INTERVAL), "How often to emit/reset stats.")
	flag.IntVar(&c.MaxAttempts, "max-attempts", DEFAULT_MAX_ATTEMPTS, "Max number of retries.")
	flag.IntVar(&c.InputFormat, "input-format", DEFAULT_INPUT_FORMAT, "0=raw (default), 1=rfc3164 (syslog(3))")
	flag.IntVar(&c.NumBatchers, "num-batchers", 2, "The number of batchers to run.")
	flag.IntVar(&c.NumOutlets, "num-outlets", 4, "The number of outlets to run.")
	flag.DurationVar(&c.WaitDuration, "wait", time.Duration(DEFAULT_WAIT_DURATION), "Duration to wait to flush messages to logplex")
	flag.IntVar(&c.BatchSize, "batch-size", 500, "Number of messages to pack into a logplex http request.")
	flag.IntVar(&c.FrontBuff, "front-buff", DEFAULT_FRONT_BUFF, "Number of messages to buffer in log-shuttle's input chanel.")
	flag.IntVar(&c.StatsBuff, "stats-buff", DEFAULT_STATS_BUFF, "Number of stats to buffer.")
	flag.DurationVar(&c.Timeout, "timeout", time.Duration(DEFAULT_TIMEOUT), "Duration to wait for a response from Logplex.")
	flag.BoolVar(&c.LogToSyslog, "log-to-syslog", false, "Log to syslog instead of stderr")
	flag.Parse()

	if c.MaxAttempts < 1 {
		log.Fatalf("-max-attempts must be >= 1")
	}
}
开发者ID:scottarthur,项目名称:log-shuttle,代码行数:32,代码来源:config.go


示例11: init

func init() {
	flag.StringVar(&join, "join", "", "Member of SkyDNS cluster to join can be comma separated list")
	flag.BoolVar(&discover, "discover", false, "Auto discover SkyDNS cluster. Performs an NS lookup on the -domain to find SkyDNS members")
	flag.StringVar(&domain, "domain",
		func() string {
			if x := os.Getenv("SKYDNS_DOMAIN"); x != "" {
				return x
			}
			return "skydns.local"
		}(), "Domain to anchor requests to or env. var. SKYDNS_DOMAIN")
	flag.StringVar(&ldns, "dns",
		func() string {
			if x := os.Getenv("SKYDNS_DNS"); x != "" {
				return x
			}
			return "127.0.0.1:53"
		}(), "IP:Port to bind to for DNS or env. var SKYDNS_DNS")
	flag.StringVar(&lhttp, "http",
		func() string {
			if x := os.Getenv("SKYDNS"); x != "" {
				// get rid of http or https
				x1 := strings.TrimPrefix(x, "https://")
				x1 = strings.TrimPrefix(x1, "http://")
				return x1
			}
			return "127.0.0.1:8080"
		}(), "IP:Port to bind to for HTTP or env. var. SKYDNS")
	flag.StringVar(&dataDir, "data", "./data", "SkyDNS data directory")
	flag.DurationVar(&rtimeout, "rtimeout", 2*time.Second, "Read timeout")
	flag.DurationVar(&wtimeout, "wtimeout", 2*time.Second, "Write timeout")
	flag.StringVar(&secret, "secret", "", "Shared secret for use with http api")
	flag.StringVar(&nameserver, "nameserver", "", "Nameserver address to forward (non-local) queries to e.g. 8.8.8.8:53,8.8.4.4:53")
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:33,代码来源:main.go


示例12: New

// Builds a conf data structure and connects
// the fields in the struct to flags.
// It is up to the caller to call flag.Parse()
func New() *D {
	d := new(D)

	flag.BoolVar(&d.PrintVersion, "version", false,
		"Print l2met version and sha.")

	flag.StringVar(&d.AppName, "app-name", "l2met",
		"Prefix internal log messages with this value.")

	flag.IntVar(&d.BufferSize, "buffer", 1024,
		"Max number of items for all internal buffers.")

	flag.IntVar(&d.Concurrency, "concurrency", 10,
		"Number of running go routines for outlet or receiver.")

	flag.IntVar(&d.Port, "port", 8080,
		"HTTP server's bind port.")

	flag.IntVar(&d.OutletRetries, "outlet-retry", 2,
		"Number of attempts to outlet metrics to Librato.")

	flag.Int64Var(&d.ReceiverDeadline, "recv-deadline", 2,
		"Number of time units to pass before dropping incoming logs.")

	flag.DurationVar(&d.OutletTtl, "outlet-ttl", time.Second*2,
		"Timeout set on Librato HTTP requests.")

	flag.Uint64Var(&d.MaxPartitions, "partitions", uint64(1),
		"Number of partitions to use for outlets.")

	flag.DurationVar(&d.FlushInterval, "flush-interval", time.Second,
		"Time to wait before sending data to store or outlet. "+
			"Example:60s 30s 1m")

	flag.DurationVar(&d.OutletInterval, "outlet-interval", time.Second,
		"Time to wait before outlets read buckets from the store. "+
			"Example:60s 30s 1m")

	flag.BoolVar(&d.UseOutlet, "outlet", false,
		"Start the Librato outlet.")

	flag.BoolVar(&d.UsingReciever, "receiver", false,
		"Enable the Receiver.")

	flag.BoolVar(&d.Verbose, "v", false,
		"Enable verbose log output.")

	d.RedisHost, d.RedisPass, _ = parseRedisUrl(env("REDIS_URL"))
	d.Secrets = strings.Split(mustenv("SECRETS"), ":")

	if len(env("METCHAN_URL")) > 0 {
		url, err := url.Parse(env("METCHAN_URL"))
		if err == nil {
			d.MetchanUrl = url
		}
	}

	return d
}
开发者ID:ryandotsmith,项目名称:l2met,代码行数:62,代码来源:conf.go


示例13: TransportFlag

// TransportFlag - A Flag configured Transport instance.
func TransportFlag(name string) *Transport {
	t := &Transport{TLSClientConfig: &tls.Config{}}
	flag.BoolVar(
		&t.TLSClientConfig.InsecureSkipVerify,
		name+".insecure-tls",
		false,
		name+" skip tls certificate verification",
	)
	flag.BoolVar(
		&t.DisableKeepAlives,
		name+".disable-keepalive",
		false,
		name+" disable keep-alives",
	)
	flag.BoolVar(
		&t.DisableCompression,
		name+".disable-compression",
		false,
		name+" disable compression",
	)
	flag.IntVar(
		&t.MaxIdleConnsPerHost,
		name+".max-idle-conns-per-host",
		http.DefaultMaxIdleConnsPerHost,
		name+" max idle connections per host",
	)
	flag.DurationVar(
		&t.DialTimeout,
		name+".dial-timeout",
		2*time.Second,
		name+" dial timeout",
	)
	flag.DurationVar(
		&t.DialKeepAlive,
		name+".dial-keepalive",
		0,
		name+" dial keepalive connection",
	)
	flag.DurationVar(
		&t.ResponseHeaderTimeout,
		name+".response-header-timeout",
		3*time.Second,
		name+" response header timeout",
	)
	flag.DurationVar(
		&t.RequestTimeout,
		name+".request-timeout",
		30*time.Second,
		name+" request timeout",
	)
	flag.UintVar(
		&t.MaxTries,
		name+".max-tries",
		0,
		name+" max retries for known safe failures",
	)
	return t
}
开发者ID:eswdd,项目名称:bosun,代码行数:59,代码来源:httpcontrol.go


示例14: init

func init() {
	flag.StringVar(&carbon, "carbon", "localhost:2003", "address of carbon host")
	flag.StringVar(&prefix, "prefix", "haggar", "prefix for metrics")
	flag.DurationVar(&flushInterval, "flush-interval", 10*time.Second, "how often to flush metrics")
	flag.DurationVar(&spawnInterval, "spawn-interval", 10*time.Second, "how often to gen new agents")
	flag.IntVar(&metrics, "metrics", 10000, "number of metrics for each agent to hold")
	flag.DurationVar(&jitter, "jitter", 10*time.Second, "max amount of jitter to introduce in between agent launches")
	flag.IntVar(&agents, "agents", 100, "max number of agents to run concurrently")
}
开发者ID:dalmatinerdb,项目名称:haggar,代码行数:9,代码来源:main.go


示例15: init

func init() {
	flag.IntVar(&params.port, "port", 8080, "Port to start app on")
	flag.DurationVar(&params.checkexpire, "checkexpire", 5*time.Second, "How often to perform check expire boxes in seconds")
	flag.IntVar(&params.freecapacity, "freecapacity", 5, "Max number of expired boxes to return to queue")
	flag.DurationVar(&params.makefreeavailable, "makefreeavailable", 5*time.Second, "How often to perform makefreeavailable")
	flag.StringVar(&params.mailboxes, "mailboxes", "vmailbox", "Postfix virtual map file")
	flag.StringVar(&params.boxpath, "boxpath", "boxes", "Path to directory with stored boxes")
	flag.Int64Var(&params.rentfor, "rentfor", 3600, "Mailbox rent time in seconds")
}
开发者ID:dronfree,项目名称:mml,代码行数:9,代码来源:mbm.go


示例16: init

func init() {
	flag.StringVar(&loadBatchTable, "load_batch_table", "load_batch", "Loads DB table for batches")
	flag.StringVar(&pendingLoadTable, "pending_load_table", "pending_load", "Loads DB table for loads")
	flag.DurationVar(&noWorkDelay, "no_work_delay", time.Minute, "Time to wait if there's no work to do")
	flag.IntVar(&maxLoadRetryCount, "max_load_retry", 5, "Number of times to retry a load batch before giving up")
	flag.IntVar(&dbRetryCount, "max_db_retry", 10, "Number of times to retry a transaction")
	flag.DurationVar(&errorRetryDelay, "error_retry_delay", time.Minute*15, "Time to wait to retry a load that errors")
	flag.DurationVar(&staleRetryDelay, "stale_retry_delay", time.Hour*3, "Time to wait before checking up on a load")
	flag.DurationVar(&staleRecoverDelay, "stale_recover_delay", time.Minute*30, "Time to check out a stale load (lock duration)")
	flag.DurationVar(&staleCheckInterval, "stale_check_interval", time.Minute, "How often to check for stale loads")
}
开发者ID:hyandell,项目名称:rs_ingester,代码行数:11,代码来源:postgres.go


示例17: main

func main() {
	addrString := flag.String("bind", ":0", "Listen [addr]:port")
	flag.DurationVar(&acceptDelay, "accept-delay", 100*time.Millisecond, "")
	flag.DurationVar(&responseDelay, "response-delay", 100*time.Millisecond, "")
	flag.Parse()

	listener, err := net.Listen("tcp", *addrString)
	if err != nil {
		log.Fatal("Listen:", err.Error())
	}
	log.Printf("Listen on http://%s/", listener.Addr())
	server(listener, delayServe)
}
开发者ID:temoto,项目名称:heroshi,代码行数:13,代码来源:slow-server.go


示例18: main

func main() {
	var config LogClientConfig
	flag.StringVar(&config.Name, "name", "log_client", "Log cilent name")
	flag.StringVar(&config.Host, "server_host", "http://localhost", "Log server host")
	flag.StringVar(&config.Port, "server_port", ":1734", "Log server listen port")
	flag.StringVar(&config.Method, "method", "/upload", "Log client method")
	flag.StringVar(&config.Dir, "dir", "/tmp/", "Upload Directory")
	flag.StringVar(&config.ListenPort, "client_listen_port", ":1735", "Log client server listening port")
	flag.DurationVar(&config.UploadInterval, "upload_interval", time.Duration(15)*time.Minute, "Upload file created before upload interval (better be smaller than keep_interval, has to be bigger than log file create interval)")
	flag.DurationVar(&config.KeepInterval, "keep_interval", time.Duration(30)*time.Minute, "Log file kept time (better be bigger than sleep_interval and upload_interval)")
	flag.DurationVar(&config.SleepInterval, "sleep_interval", time.Duration(10)*time.Minute, "Sleep time interval between every upload action (better smaller than keep_interval)")
	flag.Parse()

	// if config.KeepInterval < config.UploadInterval || config.KeepInterval < config.SleepInterval {
	// 	if config.UploadInterval >= config.SleepInterval {
	// 		config.KeepInterval = config.UploadInterval * 2
	// 		// fmt.Printf("%v\n", config.KeepInterval)
	// 	} else {
	// 		config.KeepInterval = config.SleepInterval * 2
	// 		// fmt.Printf("%v\n", config.KeepInterval)
	// 	}
	// }
	if config.Dir[len(config.Dir)-1] != '/' {
		config.Dir += "/"
	}

	glog.Infof("Log file will be kept for %v, log file will be uploaded %v after created, log client will run every %v", config.KeepInterval, config.UploadInterval, config.SleepInterval)
	fmt.Printf("Log file will be kept for %v, log file will be uploaded %v after created, log client will run every %v\n", config.KeepInterval, config.UploadInterval, config.SleepInterval)

	go func() {
		for {
			client.SendLog(config.Host+config.Port+config.Method, config.Dir, config.UploadInterval, config.KeepInterval)
			time.Sleep(config.SleepInterval)
		}
	}()

	app := ripple.NewApplication()
	logclientcontroller, err := controller.NewLogClientController("logclientserver", config.Host+config.Port+config.Method, config.Dir)
	if err != nil {
		glog.Errorf("Log client controller init failed: %v", err)
	}
	app.RegisterController("logclient", logclientcontroller)
	app.AddRoute(ripple.Route{Pattern: "sync", Controller: "logclient", Action: "Sync"})
	app.AddRoute(ripple.Route{Pattern: "favicon.ico", Controller: "logclient", Action: "Favicon"})
	app.AddRoute(ripple.Route{Pattern: "locallog", Controller: "logclient", Action: "LocalLogFile"})
	app.SetBaseUrl("/")
	http.HandleFunc("/", app.ServeHTTP)
	glog.Infof("Starting log client server at ", config.ListenPort)
	http.ListenAndServe(config.ListenPort, nil)

}
开发者ID:deepglint,项目名称:logmanager,代码行数:51,代码来源:logclient.go


示例19: init

func init() {
	flag.StringVar(&join, "join", "", "Member of SkyDNS cluster to join can be comma separated list")
	flag.BoolVar(&discover, "discover", false, "Auto discover SkyDNS cluster. Performs an NS lookup on the -domain to find SkyDNS members")
	flag.StringVar(&domain, "domain", "skydns.local", "Domain to anchor requests to")
	flag.StringVar(&ldns, "dns", "127.0.0.1:53", "IP:Port to bind to for DNS")
	flag.StringVar(&lhttp, "http", "127.0.0.1:8080", "IP:Port to bind to for HTTP")
	flag.StringVar(&dataDir, "data", "./data", "SkyDNS data directory")
	flag.DurationVar(&rtimeout, "rtimeout", 2*time.Second, "Read timeout")
	flag.DurationVar(&wtimeout, "wtimeout", 2*time.Second, "Write timeout")
	flag.BoolVar(&metricsToStdErr, "metricsToStdErr", false, "Write metrics to stderr periodically")
	flag.StringVar(&graphiteServer, "graphiteServer", "", "Graphite Server connection string e.g. 127.0.0.1:2003")
	flag.StringVar(&stathatUser, "stathatUser", "", "StatHat account for metrics")
	flag.StringVar(&secret, "secret", "", "Shared secret for use with http api")
}
开发者ID:ramarnat,项目名称:skydns,代码行数:14,代码来源:main.go


示例20: init

func init() {
	flag.StringVar(&t.ListenNetwork, "listenNetwork", t.ListenNetwork, "Listen network")
	flag.StringVar(&t.ListenAddr, "listenAddr", t.ListenAddr, "Listen address")
	flag.StringVar(&t.DialNetwork, "dialNetwork", t.DialNetwork, "Dial network")
	flag.StringVar(&t.DialAddr, "dialAddr", t.DialAddr, "Dial address")
	flag.DurationVar(&t.DialTimeout, "dialTimeout", t.DialTimeout, "Dial timeout")
	flag.DurationVar(&t.RetryTime, "retryTime", t.RetryTime, "Retry wait time")
	flag.DurationVar(&t.PipeDeadLine, "pipeDeadLine", t.PipeDeadLine, "Pipe dead line wait time")
	flag.IntVar(&t.MaxServerConnections, "maxServer", t.MaxServerConnections, "Max server connections")
	flag.IntVar(&t.MaxClinetConnections, "maxClinet", t.MaxClinetConnections, "Max client connections")
	flag.IntVar(&t.DebugLevel, "debug", t.DebugLevel, "debug level")
	flag.BoolVar(&showVer, "version", showVer, "Show version")
	flag.Parse()
}
开发者ID:masahide,项目名称:iriguchikun,代码行数:14,代码来源:main.go



注:本文中的flag.DurationVar函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang flag.Float64函数代码示例发布时间:2022-05-24
下一篇:
Golang flag.Duration函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap