本文整理汇总了Golang中github.com/grafana/grafana/pkg/bus.AddHandler函数的典型用法代码示例。如果您正苦于以下问题:Golang AddHandler函数的具体用法?Golang AddHandler怎么用?Golang AddHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddHandler函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: userQueryReturns
func (sc *scenarioContext) userQueryReturns(user *m.User) {
bus.AddHandler("test", func(query *m.GetUserByLoginQuery) error {
if user == nil {
return m.ErrUserNotFound
} else {
query.Result = user
return nil
}
})
}
开发者ID:yuvaraj951,项目名称:grafana,代码行数:10,代码来源:ldap_test.go
示例17: init
func init() {
bus.AddHandler("sql", addProcess)
bus.AddHandler("sql", GetProcess)
bus.AddHandler("sql", RemoveOrgProcess)
bus.AddHandler("sql", GetProcessById)
//bus.AddHandler("sql",UpdateProcessUser)
bus.AddHandler("sql", UpdateProcess)
bus.AddHandler("sql", GetProcessByProcessId)
bus.AddHandler("sql", GetProcessByName)
bus.AddHandler("sql", GetProcessByProcessName)
}
开发者ID:yuvaraj951,项目名称:icongrafana,代码行数:12,代码来源:process.go
示例18: init
func init() {
bus.AddHandler("sql", GetOrgQuotaByTarget)
bus.AddHandler("sql", GetOrgQuotas)
bus.AddHandler("sql", UpdateOrgQuota)
bus.AddHandler("sql", GetUserQuotaByTarget)
bus.AddHandler("sql", GetUserQuotas)
bus.AddHandler("sql", UpdateUserQuota)
bus.AddHandler("sql", GetGlobalQuotaByTarget)
}
开发者ID:Robin7Ma,项目名称:grafana,代码行数:9,代码来源:quota.go
示例19: init
func init() {
bus.AddHandler("sql", CreatePlaylist)
bus.AddHandler("sql", UpdatePlaylist)
bus.AddHandler("sql", DeletePlaylist)
bus.AddHandler("sql", SearchPlaylists)
bus.AddHandler("sql", GetPlaylist)
bus.AddHandler("sql", GetPlaylistDashboards)
bus.AddHandler("sql", GetPlaylistItem)
}
开发者ID:naveenlj,项目名称:grafana,代码行数:9,代码来源:playlist.go
示例20: init
func init() {
bus.AddHandler("sql", GetOrgById)
bus.AddHandler("sql", CreateOrg)
bus.AddHandler("sql", UpdateOrg)
bus.AddHandler("sql", UpdateOrgAddress)
bus.AddHandler("sql", GetOrgByName)
bus.AddHandler("sql", SearchOrgs)
bus.AddHandler("sql", DeleteOrg)
}
开发者ID:Robin7Ma,项目名称:grafana,代码行数:9,代码来源:org.go
注:本文中的github.com/grafana/grafana/pkg/bus.AddHandler函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论