• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang firego.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang tls.Conn类代码示例发布时间:2022-05-23
下一篇:
Golang restclient.RequestPostWithStructure函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap