本文整理匯總了Golang中github.com/goinggo/tracelog.Completed函數的典型用法代碼示例。如果您正苦於以下問題:Golang Completed函數的具體用法?Golang Completed怎麽用?Golang Completed使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Completed函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
tracelog.Start(tracelog.LevelTrace)
// Init mongo
tracelog.Started("main", "Initializing Mongo")
err := mongo.Startup(helper.MainGoRoutine)
if err != nil {
tracelog.CompletedError(err, helper.MainGoRoutine, "initApp")
os.Exit(1)
}
// Load message strings
localize.Init("en-US")
SessionConfig, err := session.GetSessionConfig("session")
tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.On)
tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.Provider)
tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.SavePath)
beego.SessionOn = SessionConfig.On
beego.SessionProvider = SessionConfig.Provider
beego.SessionSavePath = SessionConfig.SavePath
beego.Run()
tracelog.Completed(helper.MainGoRoutine, "Website Shutdown")
tracelog.Stop()
}
示例2: 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")
}
示例3: 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
}
示例4: Startup
// Startup brings the manager to a running state.
func Startup(sessionID string) error {
// If the system has already been started ignore the call.
if singleton.sessions != nil {
return nil
}
log.Started(sessionID, "Startup")
// Pull in the configuration.
var config mongoConfiguration
if err := envconfig.Process("mgo", &config); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
// Create the Mongo Manager.
singleton = mongoManager{
sessions: make(map[string]mongoSession),
}
// Create the strong session.
if err := CreateSession(sessionID, "strong", MasterSession, config.Url); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
// Create the monotonic session.
if err := CreateSession(sessionID, "monotonic", MonotonicSession, config.Url); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
log.Completed(sessionID, "Startup")
return nil
}
示例5: Shutdown
// Shutdown systematically brings the manager down gracefully.
func Shutdown(sessionID string) error {
log.Started(sessionID, "Shutdown")
// Close the databases
for _, session := range singleton.sessions {
CloseSession(sessionID, session.mongoSession)
}
log.Completed(sessionID, "Shutdown")
return nil
}
示例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 singleton.sessions {
CloseSession(sessionId, session.mongoSession)
}
tracelog.Completed(sessionId, "Shutdown")
return err
}
示例7: 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.CompletedError(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
singleton.sessions[sessionName] = mongoSession
tracelog.Completed(sessionId, "CreateSession")
return err
}
示例8: main
func main() {
tracelog.Start(tracelog.LevelTrace)
err := mongo.Startup(helper.MainGoRoutine)
if err != nil {
tracelog.CompletedError(err, helper.MainGoRoutine, "initApp")
os.Exit(1)
} else {
fmt.Println("mongodb啟動正常")
}
beego.Run()
tracelog.Completed(helper.MainGoRoutine, "Website Shutdown")
tracelog.Stop()
}
示例9: CloneSession
// CloneSession makes a clone of the specified session for client use.
func CloneSession(sessionID string, useSession string) (*mgo.Session, error) {
log.Startedf(sessionID, "CloneSession", "UseSession[%s]", useSession)
// Find the session object.
session := singleton.sessions[useSession]
if session.mongoSession == nil {
err := fmt.Errorf("Unable To Locate Session %s", useSession)
log.CompletedError(err, sessionID, "CloneSession")
return nil, err
}
// Clone the master session.
mongoSession := session.mongoSession.Clone()
log.Completed(sessionID, "CloneSession")
return mongoSession, nil
}
示例10: main
func main() {
tracelog.Start(tracelog.LevelTrace)
// Init mongo
tracelog.Started("main", "Initializing Mongo")
err := mongo.Startup(helper.MainGoRoutine)
if err != nil {
tracelog.CompletedError(err, helper.MainGoRoutine, "initApp")
os.Exit(1)
}
// Load message strings
localize.Init("en-US")
beego.Run()
tracelog.Completed(helper.MainGoRoutine, "Website Shutdown")
tracelog.Stop()
}
示例11: main
func main() {
tracelog.Start(tracelog.LEVEL_TRACE)
// Init mongo
tracelog.Started("main", "Initializing Mongo")
err := mongo.Startup(helper.MAIN_GO_ROUTINE)
if err != nil {
tracelog.CompletedError(err, helper.MAIN_GO_ROUTINE, "initApp")
os.Exit(1)
}
// Load message strings
localize.Init("en-US")
beego.Run()
tracelog.Completed(helper.MAIN_GO_ROUTINE, "Website Shutdown")
tracelog.Stop()
}
示例12: Init
// Init initializes the local environment
func Init(defaultLocale string) error {
tracelog.Startedf("localize", "Init", "defaultLocal[%s]", defaultLocale)
switch defaultLocale {
case "en-US":
LoadJSON(defaultLocale, EnUS)
default:
return fmt.Errorf("Unsupported Locale: %s", defaultLocale)
}
// Obtain the default translation function for use
var err error
if T, err = NewTranslation(defaultLocale, defaultLocale); err != nil {
return err
}
tracelog.Completed("localize", "Init")
return nil
}
示例13: Startup
// Startup brings the manager to a running state.
func Startup(sessionID string) error {
// If the system has already been started ignore the call.
if singleton.sessions != nil {
return nil
}
log.Started(sessionID, "Startup")
// Pull in the configuration.
var config mongoConfiguration
if err := envconfig.Process("mgo", &config); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
// Create the Mongo Manager.
singleton = mongoManager{
sessions: make(map[string]mongoSession),
}
// Log the mongodb connection straps.
log.Trace(sessionID, "Startup", "MongoDB : Hosts[%s]", config.Hosts)
log.Trace(sessionID, "Startup", "MongoDB : Database[%s]", config.Database)
log.Trace(sessionID, "Startup", "MongoDB : Username[%s]", config.UserName)
hosts := strings.Split(config.Hosts, ",")
// Create the strong session.
if err := CreateSession(sessionID, "strong", MasterSession, hosts, config.Database, config.UserName, config.Password); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
// Create the monotonic session.
if err := CreateSession(sessionID, "monotonic", MonotonicSession, hosts, config.Database, config.UserName, config.Password); err != nil {
log.CompletedError(err, sessionID, "Startup")
return err
}
log.Completed(sessionID, "Startup")
return nil
}
示例14: CreateSession
// CreateSession creates a connection pool for use.
func CreateSession(sessionID string, mode string, sessionName string, url string) error {
log.Startedf(sessionID, "CreateSession", "Mode[%s] Url[%s]", mode, sessionName, url)
// Create the database object
mongoSession := mongoSession{}
// Establish the master session.
var err error
mongoSession.mongoSession, err = mgo.Dial(url)
if err != nil {
log.CompletedError(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/github.com/finapps/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/github.com/finapps/mgo#Session.SetMode
mongoSession.mongoSession.SetMode(mgo.Monotonic, true)
}
// Have the session check for errors.
// http://godoc.org/github.com/finapps/mgo#Session.SetSafe
mongoSession.mongoSession.SetSafe(&mgo.Safe{})
// Add the database to the map.
singleton.sessions[sessionName] = mongoSession
log.Completed(sessionID, "CreateSession")
return nil
}
示例15: 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
}