本文整理匯總了Golang中github.com/goinggo/tracelog.COMPLETED函數的典型用法代碼示例。如果您正苦於以下問題:Golang COMPLETED函數的具體用法?Golang COMPLETED怎麽用?Golang COMPLETED使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了COMPLETED函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DecodeSlice
// DecodeSlice decodes a JSON document array into a slice of Go native objects
func DecodeSlice(doc []byte, sliceObj interface{}, obj interface{}) (bool, error) {
tracelog.STARTED("utils", "DecodeSlice")
if IsArrayResponse(doc) == false {
//decode as struct
if err := Decode(doc, obj); err != nil {
tracelog.ERROR(err, "utils", "DecodeSlice, Item Not Array, Unable to decode as struct")
return false, err
}
//return false since not an array
return false, nil
}
sliceMap := []map[string]interface{}{}
if err := json.Unmarshal(doc, &sliceMap); err != nil {
tracelog.ERROR(err, "utils", "DecodeSlice")
return false, err
}
if err := mapstructure.DecodeSlicePath(sliceMap, sliceObj); err != nil {
tracelog.ERROR(err, "utils", "DecodeSlice, Decoding Slice Object")
return false, err
}
tracelog.COMPLETED("utils", "DecodeSlice")
return true, nil
}
示例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.COMPLETED_ERROR(err, service.UserId, "FindStation")
return buoyStation, err
}
err = nil
}
tracelog.COMPLETED(service.UserId, "FindStation")
return buoyStation, err
}
示例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")
}
示例4: Finish
// Finish is called once the controller method completes
func Finish(service *services.Service) {
defer func() {
if service.MongoSession != nil {
mongo.CloseSession(service.UserId, service.MongoSession)
service.MongoSession = nil
}
}()
tracelog.COMPLETED(service.UserId, "Finish")
}
示例5: 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
}
示例6: 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
}
示例7: Station
// Station handles the higher level business processing for this API Call
func Station(controller *bc.BaseController, stationId string) {
defer bc.CatchPanic(controller, "Station")
tracelog.STARTEDf(controller.UserId, "Station", "StationId[%s]", stationId)
buoyStation, err := buoyService.FindStation(&controller.Service, stationId)
if err != nil {
tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", stationId)
controller.ServeError(err)
return
}
controller.Data["json"] = &buoyStation
controller.ServeJson()
tracelog.COMPLETED(controller.UserId, "Station")
}
示例8: Region
// Region handles the higher level business processing for this API Call
func Region(controller *bc.BaseController, region string) {
defer bc.CatchPanic(controller, "Region")
tracelog.STARTEDf(controller.UserId, "Region", "Region[%s]", region)
buoyStations, err := buoyService.FindRegion(&controller.Service, region)
if err != nil {
tracelog.COMPLETED_ERRORf(err, controller.UserId, "Region", "Region[%s]", region)
controller.ServeError(err)
return
}
controller.Data["json"] = &buoyStations
controller.ServeJson()
tracelog.COMPLETED(controller.UserId, "Region")
}
示例9: Init
// Init initializes the local environment
func Init(defaultLocale string) error {
tracelog.STARTEDf("localize", "Init", "DefaultLocal[%s]", defaultLocale)
switch defaultLocale {
default:
LoadJSON(defaultLocale, loc.En_US)
}
// Obtain the default translation function for use
var err error
T, err = NewTranslation(defaultLocale)
if err != nil {
return err
}
tracelog.COMPLETED("localize", "Init")
return nil
}
示例10: loadResponse
// loadResponse parse a response.
func loadResponse(resp *http.Response) ([]byte, error) {
tracelog.STARTED("http_client", "loadResponse")
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
tracelog.INFO("yodlee_api", "loadResponse", "Api Response => \n\n %s \n\n", contents)
if resp.StatusCode != 200 {
return nil, errors.New(string(contents))
}
tracelog.COMPLETED("http_client", "loadResponse")
return contents, err
}
示例11: 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, En_US)
default:
return fmt.Errorf("Unsupported Locale: %s", defaultLocale)
}
// Obtain the default translation function for use
var err error
T, err = NewTranslation(defaultLocale, defaultLocale)
if err != nil {
return err
}
tracelog.COMPLETED("localize", "Init")
return nil
}
示例12: 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
}
示例13: 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}
tracelog.TRACE(service.UserId, "FindRegion", "Query : %s", mongo.ToString(queryMap))
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
}
示例14: Execute
// Execute the MongoDB literal function
func Execute(sessionId string, mongoSession *mgo.Session, databaseName string, collectionName string, mongoCall MongoCall) (err error) {
tracelog.STARTEDf(sessionId, "Execute", "Database[%s] Collection[%s]", databaseName, collectionName)
// Capture the specified collection
collection, err := GetCollection(mongoSession, databaseName, collectionName)
if err != nil {
tracelog.COMPLETED_ERROR(err, sessionId, "Execute")
return err
}
// Execute the mongo call
err = mongoCall(collection)
if err != nil {
tracelog.COMPLETED_ERROR(err, sessionId, "Execute")
return err
}
tracelog.COMPLETED(sessionId, "Execute")
return err
}
示例15: IsTokenValid
// IsTokenValid checks whether a token is valid for a Secure Entity.
func IsTokenValid(secureEntity SecureEntity, token string) error {
tracelog.STARTED("Utils", "IsValidToken")
decodedToken, err := base64.StdEncoding.DecodeString(token)
if err != nil {
tracelog.ERRORf(err, "Utils", "Utils.IsValidToken", "Error Decoding Passed In Token, %s", token)
return err
}
entityToken, tErr := secureEntity.TokenBytes()
if tErr != nil {
tracelog.ERRORf(tErr, "Utils", "Utils.IsValidToken", "Error Generating Token for Entity")
return tErr
}
if hmac.Equal(decodedToken, entityToken) == false {
tracelog.ERRORf(err, "Utils", "Utils.IsValidToken", "Invalid Token Comparison,Tokens Are not the same, Invalid Token, entity[%s], decoded[%s]", string(entityToken), string(decodedToken))
return errors.New("Invalid Token")
}
tracelog.COMPLETED("Utils", "IsValidToken, Token Is Valid")
return nil
}