func newIndex(args ...interface{} /* Store */) Index { var raw = n.Resolve(rf.TypeOf((*data.Store)(nil)), 0, args...) if raw == nil { n.Log("Failed to create index service: No Store binding") return nil } var rtn = &index{ db: raw.(data.Store), } // Register types we're going to have to work with. { var t model.Index rtn.db.Register(rf.TypeOf(&t), "worker.Index") } return rtn }
func newFragments(args ...interface{} /* Store */) Fragments { var raw = n.Resolve(rf.TypeOf((*data.Store)(nil)), 0, args...) if raw == nil { n.Log("Failed to create fragment service: No Store binding") return nil } var rtn = &fragments{ db: raw.(data.Store), index: newIndex(), } // Register types we're going to have to work with. { var t model.Tags rtn.db.Register(rf.TypeOf(&t), "worker.Tags") } { var t model.Stars rtn.db.Register(rf.TypeOf(&t), "worker.Stars") } { var t model.TagCloud rtn.db.Register(rf.TypeOf(&t), "worker.TagCloud") } { var t model.Fragment rtn.db.Register(rf.TypeOf(&t), "worker.Fragment") } { var t model.StarIndex rtn.db.Register(rf.TypeOf(&t), "worker.StarIndex") } { var t model.Index rtn.db.Register(rf.TypeOf(&t), "worker.Index") } return rtn }
func newStore(drivers ...interface{} /* Driver */) (out Store) { defer func() { var f = recover() if f != nil { n.Log("Failed to create Store: %s", f) out = nil } }() // Try resolving a driver if one isn't provided var raw = n.Resolve(rf.TypeOf((*Driver)(nil)), 0, drivers...) if raw == nil { n.Log("Failed to create Store: No binding for Driver found") return nil } var rtn = &store{ types: make(map[string]rf.Type), driver: raw.(Driver), } return rtn }