本文整理汇总了Golang中github.com/CloudCom/firego.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: updateView
func updateView(pid, uid string) {
if isRelevantTo(pid, uid) {
now := time.Now()
p := firego.New(userPostsURL + "/" + uid + "/" + pid)
p.Set(now)
p = firego.New(postUsersURL + "/" + pid + "/" + uid)
p.Set(now)
}
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:9,代码来源:argosy.go
示例2: putPostNode
func putPostNode(id string, p *PostNode) error {
fb := firego.New(postsURL + "/" + id)
if err := fb.Set(p); err != nil {
return err
}
return nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:7,代码来源:argosy.go
示例3: SignIn
// SignIn creates the user's posts view and starts the user's notification
// channel.
func SignIn(uid, name, imageUrl string) error {
un := UserNode{Name: name, ImageURL: imageUrl}
if err := putUserNode(uid, &un); err != nil {
return err
}
// for right now, every user is watching every post
fb := firego.New(userPostsURL + "/" + uid)
fb.Set(nil)
qns, err := getPostNodes(QuestionType)
if err != nil {
return err
}
for pid := range qns {
updateView(pid, uid)
}
c := make(chan firego.Event)
if err := fb.Watch(c); err != nil {
return err
}
// TODO: this needs to be protected by a mutex
userNotifications[uid] = c
return nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:29,代码来源:argosy.go
示例4: ExampleFirebase_IncludePriority
func ExampleFirebase_IncludePriority() {
fb := firego.New("https://someapp.firebaseio.com")
// turn on
fb.IncludePriority(true)
// turn off
fb.IncludePriority(false)
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:7,代码来源:example_test.go
示例5: ExampleFirebase_Shallow
func ExampleFirebase_Shallow() {
fb := firego.New("https://someapp.firebaseio.com")
// turn on
fb.Shallow(true)
// turn off
fb.Shallow(false)
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:7,代码来源:example_test.go
示例6: CustomerHandler
func CustomerHandler(response http.ResponseWriter, request *http.Request) {
vars := mux.Vars(request)
customer := vars["customer"]
orderId := vars["order"]
f := firego.New("https://example-app-123.firebaseio.com")
f.Auth("<FIREBASE KEY>")
var profileBuffer bytes.Buffer
profileBuffer.WriteString("/customers/")
profileBuffer.WriteString(customer)
profileBuffer.WriteString("/profile/")
var orderBuffer bytes.Buffer
orderBuffer.WriteString("/customers/")
orderBuffer.WriteString(customer)
orderBuffer.WriteString("/orders/")
orderBuffer.WriteString(orderId)
profile := f.Child(profileBuffer.String())
var p Profile
if err := profile.Value(&p); err != nil {
log.Fatal(err)
}
order := f.Child(orderBuffer.String())
var o Order
if err := order.Value(&o); err != nil {
log.Fatal(err)
}
if _, err := Mailer(p, o); err != nil {
log.Fatal(err)
}
}
开发者ID:jtkendall,项目名称:leftovers,代码行数:35,代码来源:mailgun-firebase.go
示例7: getPostNode
func getPostNode(id string) (*PostNode, error) {
fb := firego.New(postsURL + "/" + id)
v := &PostNode{}
if err := fb.Value(v); err != nil {
return nil, err
}
return v, nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:8,代码来源:argosy.go
示例8: getCommentNode
func getCommentNode(id string) (*CommentNode, error) {
fb := firego.New(commentsURL + "/" + id)
v := &CommentNode{}
if err := fb.Value(v); err != nil {
return nil, err
}
return v, nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:8,代码来源:argosy.go
示例9: NewAPI
func NewAPI(fbURL, fbSecret string) (*api, error) {
if fbURL == "" || fbSecret == "" {
return nil, errors.New("fbURL or fbSecret are empty")
}
fb := firego.New(fbURL)
fb.Auth(fbSecret)
return &api{fb: fb}, nil
}
开发者ID:zabawaba99,项目名称:trucker,代码行数:8,代码来源:api.go
示例10: getQuestionNode
func getQuestionNode(id string) (*QuestionNode, error) {
fb := firego.New(questionsURL + "/" + id)
v := &QuestionNode{}
if err := fb.Value(v); err != nil {
return nil, err
}
return v, nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:8,代码来源:argosy.go
示例11: getUser
// getUser returns a User given a UID. Note that it never returns an error;
// if a user isn't found, the User returned will have the zero value.
func getUser(uid string) User {
fb := firego.New(usersURL + "/" + uid)
var v UserNode
if err := fb.Value(&v); err != nil {
return User{}
}
return User{UID: uid, Name: v.Name, ImageURL: v.ImageURL}
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:10,代码来源:argosy.go
示例12: getAnswerNode
func getAnswerNode(id string) (*AnswerNode, error) {
fb := firego.New(answersURL + "/" + id)
v := &AnswerNode{}
if err := fb.Value(v); err != nil {
return nil, err
}
return v, nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:8,代码来源:argosy.go
示例13: ExampleFirebase_Value
func ExampleFirebase_Value() {
fb := firego.New("https://someapp.firebaseio.com/some/value")
var v interface{}
if err := fb.Value(v); err != nil {
log.Fatal(err)
}
log.Printf("My value %v\n", v)
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:9,代码来源:example_test.go
示例14: ExampleFirebase_Push
func ExampleFirebase_Push() {
fb := firego.New("https://someapp.firebaseio.com")
newRef, err := fb.Push("my-value")
if err != nil {
log.Fatal(err)
}
log.Printf("My new ref %s\n", newRef)
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:9,代码来源:example_test.go
示例15: addPostNode
func addPostNode(uid string, t PostType) (string, error) {
fb := firego.New(postsURL)
p := PostNode{Type: t, Added: time.Now(), AddedBy: uid}
n, err := fb.Push(p)
if err != nil {
return "", err
}
path := strings.Split(n.String(), "/")
return path[len(path)-1], nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:11,代码来源:argosy.go
示例16: TestFirebase
func TestFirebase(t *testing.T) {
f := firego.New("https://peekapp.firebaseio.com/testnode")
err := f.Set(struct {
Status string `json:"status"`
Message string `json:"message"`
}{"success", "sadasf"})
if err != nil {
t.Fatal(err)
}
}
开发者ID:Leland-Takamine,项目名称:peek,代码行数:11,代码来源:firebase_test.go
示例17: touchPostNode
func touchPostNode(id string) error {
// find the users that are watching this post
fb := firego.New(postUsersURL + "/" + id)
var v map[string]interface{}
if err := fb.Value(&v); err != nil {
return err
}
now := time.Now()
for uid := range v {
// notify users that this post has changed.
fb = firego.New(userPostsURL + "/" + uid + "/" + id)
fb.Set(now)
// TODO (rrossney): is it really necessary to keep a last-modified
// timestamp under postUsers?
fb = firego.New(postUsersURL + "/" + id + "/" + uid)
fb.Set(now)
}
return nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:20,代码来源:argosy.go
示例18: ExampleFirebase_Set
func ExampleFirebase_Set() {
fb := firego.New("https://someapp.firebaseio.com")
v := map[string]interface{}{
"foo": "bar",
"bar": 1,
"bez": []string{"hello", "world"},
}
if err := fb.Set(v); err != nil {
log.Fatal(err)
}
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:12,代码来源:example_test.go
示例19: getPostNodes
func getPostNodes(t PostType) (map[string]PostNode, error) {
fb := firego.New(postsURL)
var v map[string]PostNode
if err := fb.Value(&v); err != nil {
return nil, err
}
result := make(map[string]PostNode, 0)
for pk, pn := range v {
if pn.Type == t {
result[pk] = pn
}
}
return result, nil
}
开发者ID:uhhhclem,项目名称:argosy,代码行数:14,代码来源:argosy.go
示例20: ExampleFirebase_StopWatching
func ExampleFirebase_StopWatching() {
fb := firego.New("https://someapp.firebaseio.com/some/value")
notifications := make(chan firego.Event)
if err := fb.Watch(notifications); err != nil {
log.Fatal(err)
}
go func() {
for _ = range notifications {
}
log.Println("Channel closed")
}()
time.Sleep(10 * time.Millisecond) // let go routine start
fb.StopWatching()
}
开发者ID:XinyueZ,项目名称:nasaphoto-server,代码行数:16,代码来源:example_test.go
注:本文中的github.com/CloudCom/firego.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论