本文整理汇总了Golang中github.com/tsuru/tsuru/queue.Factory函数的典型用法代码示例。如果您正苦于以下问题:Golang Factory函数的具体用法?Golang Factory怎么用?Golang Factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Factory函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: notify
func notify(appName string, messages []interface{}) {
factory, err := queue.Factory()
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
return
}
q, err := factory.Get(logQueueName(appName))
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
return
}
pubSubQ, ok := q.(queue.PubSubQ)
if !ok {
log.Debugf("Queue does not support pubsub, logs only in database.")
return
}
for _, msg := range messages {
bytes, err := json.Marshal(msg)
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
continue
}
err = pubSubQ.Pub(bytes)
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
}
}
}
开发者ID:ningjh,项目名称:tsuru,代码行数:28,代码来源:log.go
示例2: NewLogListener
func NewLogListener(a *App, filterLog Applog) (*LogListener, error) {
factory, err := queue.Factory()
if err != nil {
return nil, err
}
pubSubQ, err := factory.PubSub(logQueueName(a.Name))
if err != nil {
return nil, err
}
subChan, err := pubSubQ.Sub()
if err != nil {
return nil, err
}
c := make(chan Applog, 10)
go func() {
defer close(c)
for msg := range subChan {
applog := Applog{}
err := json.Unmarshal(msg, &applog)
if err != nil {
log.Errorf("Unparsable log message, ignoring: %s", string(msg))
continue
}
if (filterLog.Source == "" || filterLog.Source == applog.Source) &&
(filterLog.Unit == "" || filterLog.Unit == applog.Unit) {
c <- applog
}
}
}()
l := LogListener{C: c, q: pubSubQ}
return &l, nil
}
开发者ID:4eek,项目名称:tsuru,代码行数:32,代码来源:log.go
示例3: SetUpTest
func (s *S) SetUpTest(c *check.C) {
s.provisioner.Reset()
repositorytest.Reset()
dbtest.ClearAllCollections(s.conn.Apps().Database)
s.createUserAndTeam(c)
platform := Platform{Name: "python"}
s.conn.Platforms().Insert(platform)
s.defaultPlan = Plan{
Name: "default-plan",
Memory: 1024,
Swap: 1024,
CpuShare: 100,
Default: true,
}
err := s.conn.Plans().Insert(s.defaultPlan)
c.Assert(err, check.IsNil)
s.Pool = "pool1"
opts := provision.AddPoolOptions{Name: s.Pool}
err = provision.AddPool(opts)
c.Assert(err, check.IsNil)
repository.Manager().CreateUser(s.user.Email)
factory, err := queue.Factory()
c.Assert(err, check.IsNil)
factory.Reset()
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:25,代码来源:suite_test.go
示例4: SetUpTest
func (s *S) SetUpTest(c *check.C) {
routertest.FakeRouter.Reset()
repositorytest.Reset()
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
dbtest.ClearAllCollections(s.conn.Apps().Database)
s.logConn, err = db.LogConn()
c.Assert(err, check.IsNil)
s.createUserAndTeam(c)
s.provisioner = provisiontest.NewFakeProvisioner()
app.Provisioner = s.provisioner
app.AuthScheme = nativeScheme
p := app.Platform{Name: "zend"}
s.conn.Platforms().Insert(p)
s.Pool = "test1"
opts := provision.AddPoolOptions{Name: "test1", Default: true}
err = provision.AddPool(opts)
c.Assert(err, check.IsNil)
repository.Manager().CreateUser(s.user.Email)
repository.Manager().CreateUser(s.adminuser.Email)
factory, err := queue.Factory()
c.Assert(err, check.IsNil)
factory.Reset()
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:25,代码来源:suite_test.go
示例5: getQueue
func getQueue() (queue.Q, error) {
queueName := "tsuru-app"
qfactory, err := queue.Factory()
if err != nil {
return nil, err
}
return qfactory.Get(queueName)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:8,代码来源:provisioner_test.go
示例6: setQueue
func setQueue() {
var err error
qfactory, err = queue.Factory()
if err != nil {
log.Fatalf("Failed to get the queue instance: %s", err)
}
_handler, err = qfactory.Handler(handle, queueName)
if err != nil {
log.Fatalf("Failed to create the queue handler: %s", err)
}
}
开发者ID:rochacon,项目名称:tsuru,代码行数:11,代码来源:queue.go
示例7: SetUpTest
func (s *S) SetUpTest(c *check.C) {
// Reset fake routers twice, first time will remove registered failures and
// allow pending enqueued tasks to run, second time (after queue is reset)
// will remove any routes added by executed queue tasks.
routertest.FakeRouter.Reset()
routertest.HCRouter.Reset()
queue.ResetQueue()
routertest.FakeRouter.Reset()
routertest.HCRouter.Reset()
err := rebuild.RegisterTask(func(appName string) (rebuild.RebuildApp, error) {
a, err := GetByName(appName)
if err == ErrAppNotFound {
return nil, nil
}
return a, err
})
c.Assert(err, check.IsNil)
config.Set("docker:router", "fake")
s.provisioner.Reset()
repositorytest.Reset()
dbtest.ClearAllCollections(s.conn.Apps().Database)
s.createUserAndTeam(c)
platform := Platform{Name: "python"}
s.conn.Platforms().Insert(platform)
s.defaultPlan = Plan{
Name: "default-plan",
Memory: 1024,
Swap: 1024,
CpuShare: 100,
Default: true,
Router: "fake",
}
err = s.conn.Plans().Insert(s.defaultPlan)
c.Assert(err, check.IsNil)
s.Pool = "pool1"
opts := provision.AddPoolOptions{Name: s.Pool, Default: true}
err = provision.AddPool(opts)
c.Assert(err, check.IsNil)
repository.Manager().CreateUser(s.user.Email)
factory, err := queue.Factory()
c.Assert(err, check.IsNil)
factory.Reset()
}
开发者ID:tsuru,项目名称:tsuru,代码行数:43,代码来源:suite_test.go
示例8: notify
func notify(appName string, messages []interface{}) {
factory, err := queue.Factory()
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
return
}
pubSubQ, err := factory.PubSub(logQueueName(appName))
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
return
}
for _, msg := range messages {
bytes, err := json.Marshal(msg)
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
continue
}
err = pubSubQ.Pub(bytes)
if err != nil {
log.Errorf("Error on logs notify: %s", err.Error())
}
}
}
开发者ID:4eek,项目名称:tsuru,代码行数:23,代码来源:log.go
注:本文中的github.com/tsuru/tsuru/queue.Factory函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论