本文整理匯總了Golang中github.com/eaigner/hood.Hood類的典型用法代碼示例。如果您正苦於以下問題:Golang Hood類的具體用法?Golang Hood怎麽用?Golang Hood使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Hood類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadWorldmap
func LoadWorldmap(_hood *hood.Hood) {
if loaded {
panic("Worldmap has already been loaded!")
}
// Load maps
var maps []entities.Map
if err := _hood.Find(&maps); err != nil {
panic(err)
}
if len(maps) > 0 {
for _, mapEntity := range maps {
mapId := int(mapEntity.MapId)
worldmap[mapId] = NewTilePointTable(mapEntity.Name)
}
numOfProcessRoutines = len(maps)
go internalLoadWorldmap(_hood)
waitForLoadComplete()
} else {
log.Warning("World", "LoadWorldmap", "No maps found in the database")
}
loaded = true
}
示例2: CreateUsersTable_1385792513_Up
func (m *M) CreateUsersTable_1385792513_Up(hd *hood.Hood) {
type Users struct {
Id hood.Id
First string
Last string
}
hd.CreateTable(&Users{})
}
示例3: CreatePostsTable_1385803004_Up
func (m *M) CreatePostsTable_1385803004_Up(hd *hood.Hood) {
type Posts struct {
Id hood.Id
Title string `validate:"presence len(2:255)" sql:"size(255)"`
Body string `validate:"presence"`
AuthorId int64
CreatedAt hood.Created
UpdatedAt hood.Updated
}
hd.CreateTable(&Posts{})
}
示例4: GetNumAliveWorkers
func GetNumAliveWorkers(tx *hood.Hood) int {
var results []IntStruct
err := tx.FindSql(&results,
`select count(*) as value
from worker
where status=$1`, WORKER_ALIVE)
if err != nil {
panic(err)
}
return results[0].Value
}
示例5: loadMoves
func (p *PlayerPokemon) loadMoves(_hood *hood.Hood) {
var pokemonMoves []entities.PlayerPokemonMove
if err := _hood.Where("pokemon_id", "=", p.GetPlayerPokemonId()).Find(&pokemonMoves); err != nil {
log.Error("PlayerPokemon", "loadMoves", "Failed to load PlayerPokemonMoves for PlayerPokemon: %d. Error: %s", p.GetPlayerPokemonId(), err.Error())
} else {
for _, move := range pokemonMoves {
if playerPokemonMove := NewPlayerPokemonMove(&move); playerPokemonMove != nil {
p.moves[playerPokemonMove.GetPlayerPokemonMoveId()] = playerPokemonMove
}
}
}
}
示例6: GetWorkflowBatch
func (rdd *Rdd) GetWorkflowBatch(tx *hood.Hood) *WorkflowBatch {
var results []WorkflowBatch
err := tx.Where("id", "=", rdd.WorkflowBatchId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("workflow batch for rdd not found")
} else {
return &results[0]
}
}
示例7: GetWorker
func GetWorker(tx *hood.Hood, id int64) *Worker {
var results []Worker
err := tx.Where("id", "=", id).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
return nil
} else {
return &results[0]
}
}
示例8: GetSegmentCopy
func GetSegmentCopy(tx *hood.Hood, segmentCopyId int64) *SegmentCopy {
var results []SegmentCopy
err := tx.Where("id", "=", segmentCopyId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("could not find segment copy with given id")
} else {
return &results[0]
}
}
示例9: GetNumSegmentsComplete
func (rdd *Rdd) GetNumSegmentsComplete(tx *hood.Hood, include *Segment) int {
var results []IntStruct
err := tx.FindSql(&results,
`select count(*) as value
from segment
where (rdd_id = $1 and status=$3)
or id = $2`, rdd.Id, include.Id, SEGMENT_COMPLETE)
if err != nil {
panic(err)
}
return results[0].Value
}
示例10: GetRdd
func (segment *Segment) GetRdd(tx *hood.Hood) *Rdd {
var results []Rdd
err := tx.Where("id", "=", segment.RddId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("could not find rdd with given id")
} else {
return &results[0]
}
}
示例11: GetWorkflow
func (workflowBatch *WorkflowBatch) GetWorkflow(tx *hood.Hood) *Workflow {
var results []Workflow
err := tx.Where("id", "=", workflowBatch.WorkflowId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("could not find workflow for the given workflow batch")
} else {
return &results[0]
}
}
示例12: GetProtojob
func (rdd *Rdd) GetProtojob(tx *hood.Hood) *Protojob {
var results []Protojob
err := tx.Where("id", "=", rdd.ProtojobId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("Rdd is missing protojob")
} else {
return &results[0]
}
}
示例13: GetLastWorkflowBatch
func (workflow *Workflow) GetLastWorkflowBatch(tx *hood.Hood) *WorkflowBatch {
var results []WorkflowBatch
err := tx.Where("workflow_id", "=", workflow.Id).OrderBy("start_time").Desc().Limit(1).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
return nil
} else {
return &results[0]
}
}
示例14: loadMoves
func loadMoves(_hood *hood.Hood) {
log.Verbose("Pokemon.Manager", "loadMoves", "Loading pokemon moves from database")
var moves []entities.Move
if err := _hood.Find(&moves); err != nil {
log.Error("Pokemon.Manager", "loadMoves", "Error while loading moves: %s", err.Error())
} else {
for _, moveEntity := range moves {
move := NewMove(&moveEntity)
movesStore[move.GetMoveId()] = move
}
}
}
示例15: GetSegment
func (segmentCopy *SegmentCopy) GetSegment(tx *hood.Hood) *Segment {
var results []Segment
err := tx.Where("id", "=", segmentCopy.SegmentId).Find(&results)
if err != nil {
panic(err)
}
if len(results) == 0 {
panic("could not find rdd with given id")
} else {
return &results[0]
}
}