當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cpolicy.New函數代碼示例

本文整理匯總了Golang中github.com/intelsdi-x/snap/control/plugin/cpolicy.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetConfigPolicy

func (rmq *rmqPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	r1, err := cpolicy.NewStringRule("address", true)
	handleErr(err)
	r1.Description = "RabbitMQ Address (host:port)"
	config.Add(r1)

	r2, err := cpolicy.NewStringRule("exchange_name", true)
	handleErr(err)
	r2.Description = "RabbitMQ Exchange Name"
	config.Add(r2)

	r3, err := cpolicy.NewStringRule("exchange_type", true)
	handleErr(err)
	r3.Description = "RabbitMQ Exchange Type"
	config.Add(r3)

	r4, err := cpolicy.NewStringRule("routing_key", true)
	handleErr(err)
	r4.Description = "RabbitMQ Routing Key"
	config.Add(r4)

	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-publisher-rabbitmq,代碼行數:27,代碼來源:rmq.go

示例2: GetConfigPolicy

func (f *influxPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	r1, err := cpolicy.NewStringRule("host", true)
	handleErr(err)
	r1.Description = "Influxdb host"
	config.Add(r1)

	r2, err := cpolicy.NewIntegerRule("port", true)
	handleErr(err)
	r2.Description = "Influxdb port"
	config.Add(r2)

	r3, err := cpolicy.NewStringRule("database", true)
	handleErr(err)
	r3.Description = "Influxdb db name"
	config.Add(r3)

	r4, err := cpolicy.NewStringRule("user", true)
	handleErr(err)
	r4.Description = "Influxdb user"
	config.Add(r4)

	r5, err := cpolicy.NewStringRule("password", true)
	handleErr(err)
	r5.Description = "Influxdb password"
	config.Add(r4)

	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-publisher-influxdb,代碼行數:32,代碼來源:influx.go

示例3: GetConfigPolicy

// GetConfigPolicy returns a config policy
func (s *PostgreSQLPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	username, err := cpolicy.NewStringRule("username", true)
	handleErr(err)
	username.Description = "Username to login to the PostgreSQL server"

	password, err := cpolicy.NewStringRule("password", true)
	handleErr(err)
	password.Description = "Password to login to the PostgreSQL server"

	database, err := cpolicy.NewStringRule("database", true)
	handleErr(err)
	database.Description = "The postgresql database that data will be pushed to"

	tableName, err := cpolicy.NewStringRule("table_name", true)
	handleErr(err)
	tableName.Description = "The postgresql table within the database where information will be stored"

	hostName, err := cpolicy.NewStringRule("hostname", true, "localhost")
	handleErr(err)
	tableName.Description = "The postgresql server ip or domain name"

	port, err := cpolicy.NewIntegerRule("port", true, 5432)
	handleErr(err)
	port.Description = "The postgresql server port number"

	config.Add(username, password, database, tableName, hostName, port)

	cp.Add([]string{""}, config)
	return cp, nil

}
開發者ID:intelsdi-x,項目名稱:snap-plugin-publisher-postgresql,代碼行數:35,代碼來源:postgresql.go

示例4: GetConfigPolicy

func (s *mysqlPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	username, err := cpolicy.NewStringRule("username", false, usernameDefault)
	handleErr(err)
	username.Description = "Username to login to the MySQL server"

	password, err := cpolicy.NewStringRule("password", false, passwordDefault)
	handleErr(err)
	password.Description = "Password to login to the MySQL server"

	hostName, err := cpolicy.NewStringRule("hostname", false, hostnameDefault)
	handleErr(err)
	password.Description = "The host of MySQL service"

	port, err := cpolicy.NewStringRule("port", false, tcpPortDefault)
	handleErr(err)
	password.Description = "The host of MySQL service"

	database, err := cpolicy.NewStringRule("database", false, databaseDefault)
	handleErr(err)
	database.Description = "The MySQL database that data will be pushed to"

	tableName, err := cpolicy.NewStringRule("tablename", false, tableDefault)
	handleErr(err)
	tableName.Description = "The MySQL table within the database where information will be stored"

	config.Add(username, password, hostName, port, database, tableName)

	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-publisher-mysql,代碼行數:33,代碼來源:mysql.go

示例5: GetConfigPolicy

func (m *mockSessionStatePluginProxy) GetConfigPolicy(args []byte, reply *[]byte) error {
	cp := cpolicy.New()
	n1 := cpolicy.NewPolicyNode()
	if m.c {
		r1, _ := cpolicy.NewStringRule("name", false, "bob")
		n1.Add(r1)
		r2, _ := cpolicy.NewIntegerRule("someInt", true, 100)
		n1.Add(r2)
		r3, _ := cpolicy.NewStringRule("password", true)
		n1.Add(r3)
		r4, _ := cpolicy.NewFloatRule("somefloat", false, 3.14)
		n1.Add(r4)
		cp.Add([]string{"foo", "bar"}, n1)
	} else {
		r1, _ := cpolicy.NewIntegerRule("SomeRequiredInt", true, 1)
		r2, _ := cpolicy.NewStringRule("password", true)
		r3, _ := cpolicy.NewFloatRule("somefloat", false, 3.14)
		n1.Add(r1, r2, r3)
		cp.Add([]string{""}, n1)
	}
	cpr := plugin.GetConfigPolicyReply{Policy: cp}
	var err error
	*reply, err = m.e.Encode(cpr)
	return err
}
開發者ID:jeffweiss,項目名稱:snap,代碼行數:25,代碼來源:httpjsonrpc_test.go

示例6: GetConfigPolicy

func (rmq *rmqPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	r1, err := cpolicy.NewStringRule("uri", true)
	handleErr(err)
	r1.Description = "RabbitMQ URI (user:[email protected]:port/vhost)"
	config.Add(r1)

	r2, err := cpolicy.NewStringRule("exchange_name", true)
	handleErr(err)
	r2.Description = "RabbitMQ Exchange Name"
	config.Add(r2)

	r3, err := cpolicy.NewStringRule("exchange_type", true)
	handleErr(err)
	r3.Description = "RabbitMQ Exchange Type"
	config.Add(r3)

	r4, err := cpolicy.NewStringRule("routing_key", true)
	handleErr(err)
	r4.Description = "RabbitMQ Routing Key"
	config.Add(r4)

	r5, err := cpolicy.NewBoolRule("durable", false, true)
	handleErr(err)
	r5.Description = "RabbitMQ Durable"
	config.Add(r5)

	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-publisher-rabbitmq,代碼行數:32,代碼來源:rmq.go

示例7: GetConfigPolicy

func (f *mysqlPublisher) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()

	username, err := cpolicy.NewStringRule("username", true, "root")
	handleErr(err)
	username.Description = "Username to login to the MySQL server"

	password, err := cpolicy.NewStringRule("password", true, "root")
	handleErr(err)
	password.Description = "Password to login to the MySQL server"

	database, err := cpolicy.NewStringRule("database", true, "SNAP_TEST")
	handleErr(err)
	database.Description = "The MySQL database that data will be pushed to"

	tableName, err := cpolicy.NewStringRule("tablename", true, "info")
	handleErr(err)
	tableName.Description = "The MySQL table within the database where information will be stored"

	config.Add(username, password, database, tableName)

	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:geauxvirtual,項目名稱:snap-plugin-publisher-mysql,代碼行數:25,代碼來源:mysql.go

示例8: GetConfigPolicy

func (e *Etcd) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	c := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("etcd_host", true)
	p := cpolicy.NewPolicyNode()
	p.Add(rule)
	c.Add([]string{"intel", "etcd"}, p)
	return c, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-collector-etcd,代碼行數:8,代碼來源:etcd.go

示例9: GetConfigPolicy

func (a *Apache) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cfg := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("apache_mod_status_url", false, "http://127.0.0.1:80/server-status?auto")
	policy := cpolicy.NewPolicyNode()
	policy.Add(rule)
	cfg.Add([]string{"intel", "apache"}, policy)
	return cfg, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-collector-apache,代碼行數:8,代碼來源:apache.go

示例10: GetConfigPolicy

//GetConfigPolicy returns a ConfigPolicy for testing
func (f *nfsCollector) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	c := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("command", true)
	p := cpolicy.NewPolicyNode()
	p.Add(rule)
	c.Add([]string{"intel", "dummy", "exec"}, p)
	return c, nil
}
開發者ID:thomastaylor312,項目名稱:snap-plugin-collector-nfsclient,代碼行數:9,代碼來源:nfsclient.go

示例11: GetConfigPolicy

// GetConfigPolicy returns config policy
// It returns error in case retrieval was not successful
func (p *Plugin) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("proc_path", false, "/proc")
	node := cpolicy.NewPolicyNode()
	node.Add(rule)
	cp.Add([]string{vendor, fs, pluginName}, node)
	return cp, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-collector-cpu,代碼行數:10,代碼來源:cpu.go

示例12: GetConfigPolicy

func (p *movingAverageProcessor) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	config := cpolicy.NewPolicyNode()
	r1, err := cpolicy.NewIntegerRule("MovingAvgBufLength", true)
	handleErr(err)
	r1.Description = "Buffer Length for moving average "
	config.Add(r1)
	cp.Add([]string{""}, config)
	return cp, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-processor-movingaverage,代碼行數:10,代碼來源:movingaverage.go

示例13: GetConfigPolicy

//GetConfigPolicy returns a ConfigPolicyTree for testing
func (f *Mock) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	c := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("name", false, "bob")
	rule2, _ := cpolicy.NewStringRule("password", true)
	p := cpolicy.NewPolicyNode()
	p.Add(rule)
	p.Add(rule2)
	c.Add([]string{"intel", "mock", "foo"}, p)
	return c, nil
}
開發者ID:lynxbat,項目名稱:snap,代碼行數:11,代碼來源:mock.go

示例14: GetConfigPolicy

//GetConfigPolicy returns a ConfigPolicy
func (p *SmartCollector) GetConfigPolicy() (*cpolicy.ConfigPolicy, error) {
	cp := cpolicy.New()
	rule, _ := cpolicy.NewStringRule("proc_path", false, "/proc")
	node := cpolicy.NewPolicyNode()
	node.Add(rule)
	cp.Add([]string{nsVendor, nsClass, nsType}, node)
	rule, _ = cpolicy.NewStringRule("dev_path", false, "/dev")
	node.Add(rule)
	return cp, nil
}
開發者ID:intelsdi-x,項目名稱:snap-plugin-collector-smart,代碼行數:11,代碼來源:plugin.go

示例15: TestResolvePlugin

func TestResolvePlugin(t *testing.T) {
	Convey("GetPlugin()", t, func() {
		mc := newMetricCatalog()
		lp2 := &loadedPlugin{}
		lp2.ConfigPolicy = cpolicy.New()
		lp2.Meta.Version = 2

		lp5 := &loadedPlugin{}
		lp5.ConfigPolicy = cpolicy.New()
		lp5.Meta.Version = 5

		mt2 := newMetricType(core.NewNamespace("foo", "bar"), time.Now(), lp2)
		mt5 := newMetricType(core.NewNamespace("foo", "bar"), time.Now(), lp5)

		mc.Add(mt2)
		mc.Add(mt5)

		Convey("it resolves the plugin", func() {
			Convey("for the latest version", func() {
				p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), -1)
				So(err, ShouldBeNil)
				So(p, ShouldEqual, lp5)
			})
			Convey("for the queried version", func() {
				p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), 2)
				So(err, ShouldBeNil)
				So(p, ShouldEqual, lp2)
			})
		})
		Convey("it returns an error if the metricType cannot be found", func() {
			Convey("invalid name of metric", func() {
				p, err := mc.GetPlugin(core.NewNamespace("baz", "qux"), -1)
				So(p, ShouldBeNil)
				So(err.Error(), ShouldResemble, "Metric not found: /baz/qux (version: -1)")
			})
			Convey("invalid version of metric", func() {
				p, err := mc.GetPlugin(core.NewNamespace("foo", "bar"), 6)
				So(p, ShouldBeNil)
				So(err.Error(), ShouldResemble, "Metric not found: /foo/bar (version: 6)")
			})
		})
	})
}
開發者ID:IRCody,項目名稱:snap,代碼行數:43,代碼來源:metrics_test.go


注:本文中的github.com/intelsdi-x/snap/control/plugin/cpolicy.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。