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


Golang bus.AddHandler函數代碼示例

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


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

示例1: init

func init() {
	bus.AddHandler("sql", GetApiKeys)
	bus.AddHandler("sql", GetApiKeyById)
	bus.AddHandler("sql", GetApiKeyByName)
	bus.AddHandler("sql", DeleteApiKey)
	bus.AddHandler("sql", AddApiKey)
}
開發者ID:Robin7Ma,項目名稱:grafana,代碼行數:7,代碼來源:apikey.go

示例2: ldapAutherScenario

func ldapAutherScenario(desc string, fn scenarioFunc) {
	Convey(desc, func() {
		defer bus.ClearBusHandlers()

		sc := &scenarioContext{}

		bus.AddHandler("test", func(cmd *m.CreateUserCommand) error {
			sc.createUserCmd = cmd
			sc.createUserCmd.Result = m.User{Login: cmd.Login}
			return nil
		})

		bus.AddHandler("test", func(cmd *m.AddOrgUserCommand) error {
			sc.addOrgUserCmd = cmd
			return nil
		})

		bus.AddHandler("test", func(cmd *m.UpdateOrgUserCommand) error {
			sc.updateOrgUserCmd = cmd
			return nil
		})

		bus.AddHandler("test", func(cmd *m.RemoveOrgUserCommand) error {
			sc.removeOrgUserCmd = cmd
			return nil
		})

		bus.AddHandler("test", func(cmd *m.UpdateUserCommand) error {
			sc.updateUserCmd = cmd
			return nil
		})

		fn(sc)
	})
}
開發者ID:yuvaraj951,項目名稱:grafana,代碼行數:35,代碼來源:ldap_test.go

示例3: init

func init() {

	bus.AddHandler("sql", GetMaintenanceAlerts)
	bus.AddHandler("sql", GetMaintenanceAlertsByInterval)
	bus.AddHandler("sql", UpdateMaintenanceAlert)

}
開發者ID:yuvaraj951,項目名稱:icongrafana,代碼行數:7,代碼來源:malfunalert_history.go

示例4: init

func init() {
	bus.AddHandler("sql", CreateDashboardSnapshot)
	bus.AddHandler("sql", GetDashboardSnapshot)
	bus.AddHandler("sql", DeleteDashboardSnapshot)
	bus.AddHandler("sql", SearchDashboardSnapshots)
	bus.AddHandler("sql", DeleteExpiredSnapshots)
}
開發者ID:roman-vynar,項目名稱:grafana,代碼行數:7,代碼來源:dashboard_snapshot.go

示例5: init

func init() {

	bus.AddHandler("sql", GetPendingAlertHistory)
	bus.AddHandler("sql", GetCompletedAlertHistory)
	bus.AddHandler("sql", GetPendingAlertActionHistory)
	bus.AddHandler("sql", UpdateAlertAction)
}
開發者ID:yuvaraj951,項目名稱:icongrafana,代碼行數:7,代碼來源:alert_history.go

示例6: init

func init() {
	bus.AddHandler("sql", SaveDashboard)
	bus.AddHandler("sql", GetDashboard)
	bus.AddHandler("sql", DeleteDashboard)
	bus.AddHandler("sql", SearchDashboards)
	bus.AddHandler("sql", GetDashboardTags)
}
開發者ID:chengweiv5,項目名稱:grafana,代碼行數:7,代碼來源:dashboard.go

示例7: Init

func Init() error {
	initMailQueue()

	bus.AddHandler("email", sendResetPasswordEmail)
	bus.AddHandler("email", validateResetPasswordCode)
	bus.AddHandler("email", sendEmailCommandHandler)

	bus.AddEventListener(userSignedUpHandler)

	mailTemplates = template.New("name")
	mailTemplates.Funcs(template.FuncMap{
		"Subject": subjectTemplateFunc,
	})

	templatePattern := filepath.Join(setting.StaticRootPath, setting.Smtp.TemplatesPattern)
	_, err := mailTemplates.ParseGlob(templatePattern)
	if err != nil {
		return err
	}

	if !util.IsEmail(setting.Smtp.FromAddress) {
		return errors.New("Invalid email address for smpt from_adress config")
	}

	if setting.EmailCodeValidMinutes == 0 {
		setting.EmailCodeValidMinutes = 120
	}

	return nil
}
開發者ID:reduxdj,項目名稱:grafana,代碼行數:30,代碼來源:notifications.go

示例8: init

func init() {

	bus.AddHandler("sql", GetMaintenanceHistory)
	bus.AddHandler("sql", GetMaintenanceHistoryByInterval)
	bus.AddHandler("sql", UpdateMaintenanceHistory)
	bus.AddHandler("sql", addMaintenanceActivity)

}
開發者ID:yuvaraj951,項目名稱:icongrafana,代碼行數:8,代碼來源:maintenance_history.go

示例9: init

func init() {

	bus.AddHandler("sql", GetMaintenance)
	bus.AddHandler("sql", addMaintenance)
	bus.AddHandler("sql", RemoveMaintenance)
	bus.AddHandler("sql", GetMaintenanceById)
	bus.AddHandler("sql", UpdateMaintenance)
}
開發者ID:yuvaraj951,項目名稱:icongrafana,代碼行數:8,代碼來源:Maintenance.go

示例10: TestPluginDashboards

func TestPluginDashboards(t *testing.T) {

	Convey("When asking plugin dashboard info", t, func() {
		setting.Cfg = ini.Empty()
		sec, _ := setting.Cfg.NewSection("plugin.test-app")
		sec.NewKey("path", "../../tests/test-app")
		err := Init()

		So(err, ShouldBeNil)

		bus.AddHandler("test", func(query *m.GetDashboardQuery) error {
			if query.Slug == "nginx-connections" {
				dash := m.NewDashboard("Nginx Connections")
				dash.Data.Set("revision", "1.1")
				query.Result = dash
				return nil
			}

			return m.ErrDashboardNotFound
		})

		bus.AddHandler("test", func(query *m.GetDashboardsByPluginIdQuery) error {
			var data = simplejson.New()
			data.Set("title", "Nginx Connections")
			data.Set("revision", 22)

			query.Result = []*m.Dashboard{
				{Slug: "nginx-connections", Data: data},
			}
			return nil
		})

		dashboards, err := GetPluginDashboards(1, "test-app")

		So(err, ShouldBeNil)

		Convey("should return 2 dashboarrd", func() {
			So(len(dashboards), ShouldEqual, 2)
		})

		Convey("should include installed version info", func() {
			So(dashboards[0].Title, ShouldEqual, "Nginx Connections")
			So(dashboards[0].Revision, ShouldEqual, 25)
			So(dashboards[0].ImportedRevision, ShouldEqual, 22)
			So(dashboards[0].ImportedUri, ShouldEqual, "db/nginx-connections")

			So(dashboards[1].Revision, ShouldEqual, 2)
			So(dashboards[1].ImportedRevision, ShouldEqual, 0)
		})
	})

}
開發者ID:Robin7Ma,項目名稱:grafana,代碼行數:52,代碼來源:dashboards_test.go

示例11: TestSearch

func TestSearch(t *testing.T) {

	Convey("Given search query", t, func() {
		jsonDashIndex = NewJsonDashIndex("../../../public/dashboards/")
		query := Query{Limit: 2000}

		bus.AddHandler("test", func(query *FindPersistedDashboardsQuery) error {
			query.Result = HitList{
				&Hit{Id: 16, Title: "CCAA", Tags: []string{"BB", "AA"}},
				&Hit{Id: 10, Title: "AABB", Tags: []string{"CC", "AA"}},
				&Hit{Id: 15, Title: "BBAA", Tags: []string{"EE", "AA", "BB"}},
			}
			return nil
		})

		bus.AddHandler("test", func(query *m.GetUserStarsQuery) error {
			query.Result = map[int64]bool{10: true, 12: true}
			return nil
		})

		Convey("That is empty", func() {
			err := searchHandler(&query)
			So(err, ShouldBeNil)

			Convey("should return sorted results", func() {
				So(query.Result[0].Title, ShouldEqual, "AABB")
				So(query.Result[1].Title, ShouldEqual, "BBAA")
				So(query.Result[2].Title, ShouldEqual, "CCAA")
			})

			Convey("should return sorted tags", func() {
				So(query.Result[1].Tags[0], ShouldEqual, "AA")
				So(query.Result[1].Tags[1], ShouldEqual, "BB")
				So(query.Result[1].Tags[2], ShouldEqual, "EE")
			})
		})

		Convey("That filters by tag", func() {
			query.Tags = []string{"BB", "AA"}
			err := searchHandler(&query)
			So(err, ShouldBeNil)

			Convey("should return correct results", func() {
				So(len(query.Result), ShouldEqual, 2)
				So(query.Result[0].Title, ShouldEqual, "BBAA")
				So(query.Result[1].Title, ShouldEqual, "CCAA")
			})

		})
	})
}
開發者ID:Robin7Ma,項目名稱:grafana,代碼行數:51,代碼來源:handlers_test.go

示例12: init

func init() {
	bus.AddHandler("sql", SaveAlerts)
	bus.AddHandler("sql", HandleAlertsQuery)
	bus.AddHandler("sql", GetAlertById)
	bus.AddHandler("sql", DeleteAlertById)
	bus.AddHandler("sql", GetAllAlertQueryHandler)
	bus.AddHandler("sql", SetAlertState)
	bus.AddHandler("sql", GetAlertStatesForDashboard)
	bus.AddHandler("sql", PauseAlert)
	bus.AddHandler("sql", PauseAllAlerts)
}
開發者ID:yuvaraj951,項目名稱:grafana,代碼行數:11,代碼來源:alert.go

示例13: TestPluginProxy

func TestPluginProxy(t *testing.T) {

	Convey("When getting proxy headers", t, func() {
		route := &plugins.AppPluginRoute{
			Headers: []plugins.AppPluginRouteHeader{
				{Name: "x-header", Content: "my secret {{.SecureJsonData.key}}"},
			},
		}

		setting.SecretKey = "password"

		bus.AddHandler("test", func(query *m.GetPluginSettingByIdQuery) error {
			query.Result = &m.PluginSetting{
				SecureJsonData: map[string][]byte{
					"key": util.Encrypt([]byte("123"), "password"),
				},
			}
			return nil
		})

		header, err := getHeaders(route, 1, "my-app")
		So(err, ShouldBeNil)

		Convey("Should render header template", func() {
			So(header.Get("x-header"), ShouldEqual, "my secret 123")
		})
	})

}
開發者ID:Xetius,項目名稱:grafana,代碼行數:29,代碼來源:pluginproxy_test.go

示例14: init

func init() {
	bus.AddHandler("sql", SaveDashboard)
	bus.AddHandler("sql", GetDashboard)
	bus.AddHandler("sql", GetDashboards)
	bus.AddHandler("sql", DeleteDashboard)
	bus.AddHandler("sql", SearchDashboards)
	bus.AddHandler("sql", GetDashboardTags)
	bus.AddHandler("sql", GetDashboardSlugById)
	bus.AddHandler("sql", GetDashboardsByPluginId)
}
開發者ID:utkarshcmu,項目名稱:grafana,代碼行數:10,代碼來源:dashboard.go

示例15: init

func init() {
	bus.AddHandler("sql", GetMonitors)
	bus.AddHandler("sql", GetMonitorsForAlerts)
	bus.AddHandler("sql", GetMonitorById)
	bus.AddHandler("sql", GetMonitorTypes)
	bus.AddHandler("sql", AddMonitor)
	bus.AddHandler("sql", UpdateMonitor)
	bus.AddHandler("sql", DeleteMonitor)
	bus.AddHandler("sql", UpdateMonitorState)
}
開發者ID:ronpastore,項目名稱:grafana,代碼行數:10,代碼來源:monitor.go


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