Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d784a26
Fixed static content path
kris-lab Jan 25, 2015
af80703
UnixNano() time accuracy
kris-lab Jan 26, 2015
448a299
Renamed rpc to P2P
kris-lab Jan 26, 2015
e14104f
Cleaned up streaming platform
kris-lab Jan 26, 2015
fa547fc
Cleaned up JS client
kris-lab Jan 26, 2015
3cafe74
Formatting; Naming
kris-lab Jan 26, 2015
f0f5aba
Introduced ChannelEvent and SystemEvent
kris-lab Jan 26, 2015
5b8ddf3
Introduced ChannelEvent, SystemEvent
kris-lab Jan 27, 2015
6b0233f
Introduced NewFeedEvent and NewEntryEvent on backend site
kris-lab Jan 27, 2015
553e367
Introduced FeedEvent and EntryEvent on frontend site
kris-lab Jan 27, 2015
a39e83f
Reorganized protocol messages stack
kris-lab Jan 27, 2015
37be340
Added events to channel
kris-lab Jan 27, 2015
eeacf5e
Moved authentication layer to feed
kris-lab Jan 27, 2015
1d15d18
Moved credential to feed
kris-lab Jan 27, 2015
6646110
Formatting
kris-lab Jan 27, 2015
f65e51b
Feed instance skeleton
kris-lab Jan 27, 2015
41798d7
Added service/system with some basic metrics
kris-lab Jan 28, 2015
4ff7cd3
Extended system status metrics
kris-lab Jan 28, 2015
a4ffc9d
Renamed system controller to status controller
kris-lab Jan 28, 2015
a9c8dfd
Restructured routers; add /service/ prefix to /api and /stream; added…
kris-lab Jan 28, 2015
83a33d0
Added session manager
kris-lab Jan 28, 2015
c6f3dd7
Renamed api service with db service
kris-lab Jan 28, 2015
a9c92be
Updated routers
kris-lab Jan 28, 2015
31a8a33
Extended system status metrics; Bug fixes;
kris-lab Jan 28, 2015
4442222
Extended system status metrics;
kris-lab Jan 28, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resource/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func AddEntry(feedEntry Entry, FeedId string, ApplicationId string, OrgId string

// notify
data, _ := json.Marshal(entry)
room.Publish <- room.NewEvent(model.EVENT_MESSAGE, "system", string(data))
room.Publish <- room.NewEntryEvent(model.EVENT_MESSAGE, "system", string(data))

return feedEntry.Id, nil
}
Expand Down
2 changes: 1 addition & 1 deletion resource/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func AddFeed(feed Feed, applicationId string, orgId string) (id string, err erro

// notify
data, _ := json.Marshal(feed)
room.Publish <- room.NewEvent(model.EVENT_MESSAGE, "system", string(data))
room.Publish <- room.NewFeedEvent(model.EVENT_MESSAGE, "system", string(data))

return feed.Id, nil
}
Expand Down
7 changes: 0 additions & 7 deletions service/api/api.go

This file was deleted.

8 changes: 0 additions & 8 deletions service/api/v1/api.go

This file was deleted.

7 changes: 7 additions & 0 deletions service/db/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package api

import (
_ "github.com/feedlabs/elasticfeed/service/db/v1"
)

func init() {}
8 changes: 8 additions & 0 deletions service/db/v1/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package v1

import (
_ "github.com/feedlabs/elasticfeed/service/db/v1/router"
_ "github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template/admin"
"github.com/feedlabs/elasticfeed/service/db/v1/template/admin"
)

type AdminController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template/application"
"github.com/feedlabs/elasticfeed/service/db/v1/template/application"
)

type ApplicationController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/helper"
"github.com/feedlabs/elasticfeed/service/api/v1/template"
"github.com/feedlabs/elasticfeed/service/db/v1/template"
)

type DefaultController struct {
Expand Down Expand Up @@ -70,5 +70,5 @@ func NoRoutes() {
func init() {
SetAuthenticationFilter()
SetGlobalResponseHeader()
// NoRoutes()
// NoRoutes()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template/entry"
"github.com/feedlabs/elasticfeed/service/db/v1/template/entry"
)

type EntryController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template/feed"
"github.com/feedlabs/elasticfeed/service/db/v1/template/feed"
)

type FeedController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
template "github.com/feedlabs/elasticfeed/service/api/v1/template/org"
template "github.com/feedlabs/elasticfeed/service/db/v1/template/org"
)

type OrgController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template/token"
"github.com/feedlabs/elasticfeed/service/db/v1/template/token"
)

type TokenController struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package router

import (
"github.com/feedlabs/feedify"
"github.com/feedlabs/elasticfeed/service/api/v1/controller"
"github.com/feedlabs/elasticfeed/service/db/v1/controller"
)

func init() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org
import (
"errors"
"github.com/feedlabs/feedify/context"
"github.com/feedlabs/elasticfeed/service/api/v1/template"
"github.com/feedlabs/elasticfeed/service/db/v1/template"
)

func CheckRequiredParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org
import (
"strconv"
"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/service/api/v1/template"
"github.com/feedlabs/elasticfeed/service/db/v1/template"
"errors"
"sort"
)
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion service/service.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package service

import (
_ "github.com/feedlabs/elasticfeed/service/api"
_ "github.com/feedlabs/elasticfeed/service/db"
_ "github.com/feedlabs/elasticfeed/service/stream"
_ "github.com/feedlabs/elasticfeed/service/system"
)

func init() {}
24 changes: 17 additions & 7 deletions service/stream/controller/channel/long_pooling.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,32 @@ type LongPollingController struct {
}

func (this *LongPollingController) Join() {
uname := this.GetString("uname")
if len(uname) == 0 {
chid := this.GetString("chid")
if len(chid) == 0 {
return
}

room.Join(uname, nil)
w := this.GetCtx().ResponseWriter
r := this.GetCtx().Input.Request
sess := room.GlobalSessions.SessionStart(w, r)
defer sess.SessionRelease(w)

room.Join(chid, nil)
}

func (this *LongPollingController) Post() {
uname := this.GetString("uname")
content := this.GetString("content")
if len(uname) == 0 || len(content) == 0 {
chid := this.GetString("chid")
data := this.GetString("data")
if len(chid) == 0 || len(data) == 0 {
return
}

room.Publish <- room.NewEvent(model.EVENT_MESSAGE, uname, content)
// Feature:
// or specific request for this client;
// should be executed and returned directly to user
// lastReceived time should not be changed in that case

room.Publish <- room.NewSystemEvent(model.EVENT_MESSAGE, chid, data)
}

func (this *LongPollingController) Fetch() {
Expand Down
19 changes: 12 additions & 7 deletions service/stream/controller/channel/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ type WebSocketController struct {
}

func (this *WebSocketController) Join() {
uname := this.GetString("uname")
if len(uname) == 0 {
chid := this.GetString("chid")
if len(chid) == 0 {
return
}

ws, err := websocket.Upgrade(this.Ctx.ResponseWriter, this.Ctx.Request, nil, 1024, 1024)
w := this.GetCtx().ResponseWriter
r := this.GetCtx().Input.Request
sess := room.GlobalSessions.SessionStart(w, r)
defer sess.SessionRelease(w)

ws, err := websocket.Upgrade(w, r, nil, 1024, 1024)
if _, ok := err.(websocket.HandshakeError); ok {
http.Error(this.Ctx.ResponseWriter, "Not a websocket handshake", 400)
return
Expand All @@ -29,16 +34,16 @@ func (this *WebSocketController) Join() {
return
}

room.Join(uname, ws)
defer room.Leave(uname)
room.Join(chid, ws)
defer room.Leave(chid)

for {
_, p, err := ws.ReadMessage()
if err != nil {
return
}
room.Publish <- room.NewEvent(model.EVENT_MESSAGE, uname, string(p))

room.System_rpc <- ws
room.Publish <- room.NewSystemEvent(model.EVENT_MESSAGE, chid, string(p))
room.P2P <- ws
}
}
Loading