本文整理汇总了Golang中github.com/goinggo/beego-mgo/utilities/helper.CatchPanic函数的典型用法代码示例。如果您正苦于以下问题:Golang CatchPanic函数的具体用法?Golang CatchPanic怎么用?Golang CatchPanic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CatchPanic函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CloseSession
// CloseSession puts the connection back into the pool
func CloseSession(sessionId string, mongoSession *mgo.Session) {
defer helper.CatchPanic(nil, sessionId, "CloseSession")
tracelog.Started(sessionId, "CloseSession")
mongoSession.Close()
tracelog.Completed(sessionId, "CloseSession")
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:8,代码来源:mongo.go
示例2: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindStation")
tracelog.Started(service.UserId, "FindStation")
queryMap := bson.M{"station_id": stationId}
buoyStation = &buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
tracelog.Trace(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))
return collection.Find(queryMap).One(buoyStation)
})
if err != nil {
if strings.Contains(err.Error(), "not found") == false {
tracelog.CompletedError(err, service.UserId, "FindStation")
return buoyStation, err
}
err = nil
}
tracelog.Completed(service.UserId, "FindStation")
return buoyStation, err
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:27,代码来源:buoyService.go
示例3: CloseSession
// CloseSession puts the connection back into the pool
func CloseSession(sessionId string, mongoSession *mgo.Session) {
defer helper.CatchPanic(nil, sessionId, "CloseSession")
tracelog.STARTED(sessionId, "CloseSession")
mongoSession.Close()
tracelog.COMPLETED(sessionId, "CloseSession")
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:10,代码来源:mongo.go
示例4: Finish
// Finish is called after the controller.
func (service *Service) Finish() (err error) {
defer helper.CatchPanic(&err, service.UserID, "Service.Finish")
if service.MongoSession != nil {
mongo.CloseSession(service.UserID, service.MongoSession)
service.MongoSession = nil
}
return err
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:11,代码来源:services.go
示例5: Finish
func (this *Service) Finish() (err error) {
defer helper.CatchPanic(&err, this.UserId, "Service.Finish")
if this.MongoSession != nil {
mongo.CloseSession(this.UserId, this.MongoSession)
this.MongoSession = nil
}
return err
}
开发者ID:pmljm,项目名称:beego-mgo,代码行数:10,代码来源:services.go
示例6: Shutdown
// Shutdown systematically brings the manager down gracefully
func Shutdown(sessionId string) (err error) {
defer helper.CatchPanic(&err, sessionId, "Shutdown")
tracelog.STARTED(sessionId, "Shutdown")
// Close the databases
for _, session := range _This.sessions {
CloseSession(sessionId, session.mongoSession)
}
tracelog.COMPLETED(sessionId, "Shutdown")
return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:14,代码来源:mongo.go
示例7: Shutdown
// Shutdown systematically brings the manager down gracefully
func Shutdown(sessionId string) (err error) {
defer helper.CatchPanic(&err, sessionId, "Shutdown")
tracelog.Started(sessionId, "Shutdown")
// Close the databases
for _, session := range singleton.sessions {
CloseSession(sessionId, session.mongoSession)
}
tracelog.Completed(sessionId, "Shutdown")
return err
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:14,代码来源:mongo.go
示例8: CreateSession
// CreateSession creates a connection pool for use
func CreateSession(sessionId string, mode string, sessionName string, hosts []string, databaseName string, username string, password string) (err error) {
defer helper.CatchPanic(nil, sessionId, "CreateSession")
tracelog.STARTEDf(sessionId, "CreateSession", "Mode[%s] SessionName[%s] Hosts[%s] DatabaseName[%s] Username[%s]", mode, sessionName, hosts, databaseName, username)
// Create the database object
mongoSession := &mongoSession{
mongoDBDialInfo: &mgo.DialInfo{
Addrs: hosts,
Timeout: 60 * time.Second,
Database: databaseName,
Username: username,
Password: password,
},
}
// Establish the master session
mongoSession.mongoSession, err = mgo.DialWithInfo(mongoSession.mongoDBDialInfo)
if err != nil {
tracelog.COMPLETED_ERROR(err, sessionId, "CreateSession")
return err
}
switch mode {
case "strong":
// Reads and writes will always be made to the master server using a
// unique connection so that reads and writes are fully consistent,
// ordered, and observing the most up-to-date data.
// http://godoc.org/labix.org/v2/mgo#Session.SetMode
mongoSession.mongoSession.SetMode(mgo.Strong, true)
break
case "monotonic":
// Reads may not be entirely up-to-date, but they will always see the
// history of changes moving forward, the data read will be consistent
// across sequential queries in the same session, and modifications made
// within the session will be observed in following queries (read-your-writes).
// http://godoc.org/labix.org/v2/mgo#Session.SetMode
mongoSession.mongoSession.SetMode(mgo.Monotonic, true)
}
// Have the session check for errors
// http://godoc.org/labix.org/v2/mgo#Session.SetSafe
mongoSession.mongoSession.SetSafe(&mgo.Safe{})
// Add the database to the map
_This.sessions[sessionName] = mongoSession
tracelog.COMPLETED(sessionId, "CreateSession")
return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:52,代码来源:mongo.go
示例9: CloneSession
// CopySession makes a clone of the specified session for client use
func CloneSession(sessionId string, useSession string) (mongoSession *mgo.Session, err error) {
defer helper.CatchPanic(nil, sessionId, "CopySession")
tracelog.STARTEDf(sessionId, "CloneSession", "UseSession[%s]", useSession)
// Find the session object
session := _This.sessions[useSession]
if session == nil {
err = fmt.Errorf("Unable To Locate Session %s", useSession)
tracelog.COMPLETED_ERROR(err, sessionId, "CloneSession")
return mongoSession, err
}
// Clone the master session
mongoSession = session.mongoSession.Clone()
tracelog.COMPLETED(sessionId, "CloneSession")
return mongoSession, err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:21,代码来源:mongo.go
示例10: CloneSession
// CopySession makes a clone of the specified session for client use
func CloneSession(sessionId string, useSession string) (mongoSession *mgo.Session, err error) {
defer helper.CatchPanic(nil, sessionId, "CopySession")
tracelog.Startedf(sessionId, "CloneSession", "UseSession[%s]", useSession)
// Find the session object
session := singleton.sessions[useSession]
if session == nil {
err = fmt.Errorf("Unable To Locate Session %s", useSession)
tracelog.CompletedError(err, sessionId, "CloneSession")
return mongoSession, err
}
// Clone the master session
mongoSession = session.mongoSession.Clone()
tracelog.Completed(sessionId, "CloneSession")
return mongoSession, err
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:21,代码来源:mongo.go
示例11: FindRegion
// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) (buoyStations []*buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindRegion")
tracelog.Started(service.UserId, "FindRegion")
queryMap := bson.M{"region": region}
buoyStations = []*buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
tracelog.Trace(service.UserId, "FindRegion", "Query : %s", mongo.ToString(queryMap))
return collection.Find(queryMap).All(&buoyStations)
})
if err != nil {
tracelog.CompletedError(err, service.UserId, "FindRegion")
return buoyStations, err
}
tracelog.Completed(service.UserId, "FindRegion")
return buoyStations, err
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:23,代码来源:buoyService.go
示例12: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindStation")
tracelog.STARTED(service.UserId, "FindStation")
queryMap := bson.M{"station_id": stationId}
tracelog.TRACE(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))
buoyStation = &buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
return collection.Find(queryMap).One(buoyStation)
})
if err != nil {
tracelog.COMPLETED_ERROR(err, service.UserId, "FindStation")
return buoyStation, err
}
tracelog.COMPLETED(service.UserId, "FindStation")
return buoyStation, err
}
开发者ID:pmljm,项目名称:beego-mgo,代码行数:23,代码来源:buoyService.go
示例13: Startup
// Startup brings the manager to a running state
func Startup(sessionId string) (err error) {
defer helper.CatchPanic(&err, sessionId, "Startup")
// If the system has already been started ignore the call
if _This != nil {
return err
}
tracelog.STARTED(sessionId, "Startup")
// Pull in the configuration
config := mongoConfiguration{}
err = envconfig.Process("mgo", &config)
if err != nil {
tracelog.COMPLETED_ERROR(err, sessionId, "Startup")
return err
}
// Create the Mongo Manager
_This = &mongoManager{
sessions: map[string]*mongoSession{},
}
// Log the mongodb connection straps
tracelog.TRACE(sessionId, "Startup", "MongoDB : Hosts[%s]", config.Hosts)
tracelog.TRACE(sessionId, "Startup", "MongoDB : Database[%s]", config.Database)
tracelog.TRACE(sessionId, "Startup", "MongoDB : Username[%s]", config.UserName)
hosts := strings.Split(config.Hosts, ",")
// Create the strong and monotonic sessions
err = CreateSession(sessionId, "strong", MASTER_SESSION, hosts, config.Database, config.UserName, config.Password)
err = CreateSession(sessionId, "monotonic", MONOTONIC_SESSION, hosts, config.Database, config.UserName, config.Password)
tracelog.COMPLETED(sessionId, "Startup")
return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:38,代码来源:mongo.go
示例14: FindRegion
// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) (buoyStations []*buoyModels.BuoyStation, err error) {
defer helper.CatchPanic(&err, service.UserId, "FindRegion")
tracelog.STARTED(service.UserId, "FindRegion")
// Find the specified region
queryMap := bson.M{"region": region}
tracelog.TRACE(service.UserId, "FindRegion", "Query : %s", mongo.ToString(queryMap))
// Capture the specified buoy
buoyStations = []*buoyModels.BuoyStation{}
err = service.DBAction(Config.Database, "buoy_stations",
func(collection *mgo.Collection) error {
return collection.Find(queryMap).All(&buoyStations)
})
if err != nil {
tracelog.COMPLETED_ERROR(err, service.UserId, "FindRegion")
return buoyStations, err
}
tracelog.COMPLETED(service.UserId, "FindRegion")
return buoyStations, err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:25,代码来源:buoyService.go
注:本文中的github.com/goinggo/beego-mgo/utilities/helper.CatchPanic函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论