Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ package by specifying the `TEST` variable. For example below, only


#### Run
`go run api.go`
Environment variables for plugins
```
export ELASTICFEED_PLUGIN_MIN_PORT=40000
export ELASTICFEED_PLUGIN_MAX_PORT=41000
```
Compilation and running
```
go run api.go
```

#### Dependencies
* `go get github.com/feedlabs/feedify` [repo](https://github.com/feedlabs/feedify)
Expand Down
23 changes: 22 additions & 1 deletion common/config/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
"strconv"
"github.com/feedlabs/feedify"
)

Expand Down Expand Up @@ -30,6 +31,26 @@ func GetPluginStoragePath() string {
return feedify.GetConfigKey("plugin-manager::storage")
}

func GetPluginPortMin() uint {
port, err := strconv.ParseUint(feedify.GetConfigKey("plugin-manager::port_min"), 10, 0)

if err == nil {
return uint(port)
}

return 40000
}

func GetPluginPortMax() uint {
port, err := strconv.ParseUint(feedify.GetConfigKey("plugin-manager::port_max"), 10, 0)

if err == nil {
return uint(port)
}

return 41000
}

func GetHomeAbsolutePath() string {
pwd, _ := os.Getwd()
return pwd
Expand All @@ -43,7 +64,7 @@ func init() {
os.Exit(1)
}

path := GetHomeAbsolutePath() + "/" + feedify.GetConfigKey("plugin-manager::storage")
path := GetHomeAbsolutePath() + "/" + GetPluginStoragePath()
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(path, 0777)
Expand Down
37 changes: 23 additions & 14 deletions conf/app.conf
Original file line number Diff line number Diff line change
@@ -1,58 +1,69 @@
appname=feedify
appname=elasticfeed
runmode=dev
autorender=false
copyrequestbody=true

# Global configuration
[feedify]
port=10100
# enable restful api
rest=on
# enable websocket interface
websocket=on
# enable scenario engine
scenario=off
# enable crwaler and indexer
crawler=off

[api]
su=x-super-user
key=supersecret
whitelist=127.0.0.1

# Cluster configuration
[cluster]
# communication platform nsq|redis|none
middleware=none

# Authentication configuration
[auth]
# type can by basic|digest|none
type=digest
realm=localhost

# Service Manager configuration
[service]
cache=memcache
graph=graph
stream=stream
js=otto

[redis]
host=localhost
port=6379
protocol=tcp

# Streaming configuration
[stream]
message_adapter=socket_redis

# Graph database configuration
[graph]
storage_adapter=neo4j_cypher

# Neo4j graph database configuration
[neo4j]
host=localhost
port=7474
db=db/data

# Redis configuration
[redis]
host=localhost
port=6379
protocol=tcp

# Memcache configuration
[memcache]
host=localhost
port=11211

[graph]
storage_adapter=neo4j_cypher
# Plugin Manager configuration
[plugin-manager]
storage=public/userfiles/plugin/imports
port_min=40000
port_max=41000

# for distributed cluster if
# scenario mode is enabled (see [feedify])
Expand All @@ -62,5 +73,3 @@ host=localhost
port=1111
topic=feed

[plugin-manager]
storage=public/userfiles/plugin/imports
8 changes: 8 additions & 0 deletions elasticfeed/elasticfeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/feedlabs/elasticfeed/service"
"github.com/feedlabs/elasticfeed/event"
"github.com/feedlabs/elasticfeed/resource"
"github.com/feedlabs/elasticfeed/population"

"github.com/feedlabs/feedify"
)
Expand All @@ -18,6 +19,7 @@ type Elasticfeed struct {
S model.ServiceManager
P model.PluginManager
W model.WorkflowManager
PP model.PopulationManager
}

func (this *Elasticfeed) GetEventManager() model.EventManager {
Expand All @@ -40,6 +42,10 @@ func (this *Elasticfeed) GetWorkflowManager() model.WorkflowManager {
return this.W
}

func (this *Elasticfeed) GetPopulationManager() model.PopulationManager {
return this.PP
}

func (this *Elasticfeed) GetConfig() map[string]interface {} {
return make(map[string]interface {})
}
Expand All @@ -49,6 +55,7 @@ func (this *Elasticfeed) Run() {
this.GetServiceManager().Init()
this.GetWorkflowManager().Init()
this.GetEventManager().Init()
this.GetPopulationManager().Init()

feedify.SetStaticPath("/static", "public")
feedify.Run()
Expand All @@ -63,6 +70,7 @@ func NewElasticfeed() model.Elasticfeed {
engine.P = plugin.NewPluginManager(engine)
engine.W = workflow.NewWorkflowManager(engine)
engine.S = service.NewServiceManager(engine)
engine.PP = population.NewPopulationManager(engine)

return engine
}
6 changes: 6 additions & 0 deletions elasticfeed/model/population.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package model

type PopulationManager interface {

Init()
}
4 changes: 2 additions & 2 deletions plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ func (c *PluginManager) pluginClient(path string) *Client {

func NewPluginManager(engine emodel.Elasticfeed) emodel.PluginManager {

pm := &PluginManager{engine, nil, nil, nil, nil, nil, nil, 40000, 41000}
pm := &PluginManager{engine, nil, nil, nil, nil, nil, nil, config.GetPluginPortMin(), config.GetPluginPortMax()}

pm.discover(filepath.Join(config.GetHomeAbsolutePath(), "public/userfiles/plugin/imports"))
pm.discover(filepath.Join(config.GetPluginStoragePath()))

return pm
}
1 change: 1 addition & 0 deletions plugin/model/resource_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ResourceApi struct {
func (this *ResourceApi) CreateEntryMetric() {}
func (this *ResourceApi) DeleteEntryMetric() {}
func (this *ResourceApi) UpdateEntryMetric() {}
func (this *ResourceApi) GetEntryMetric() {}

func (this *ResourceApi) ClearFeed() {}
func (this *ResourceApi) ReorderFeed() {}
Expand Down
103 changes: 103 additions & 0 deletions plugin/model/viewer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package model

/*
TODO:

**********************************************************

SHOULD BE BASICALLY A BRIDGE TO PUPULATION/PERSON CLASS

**********************************************************

- VIEWER IS USED IN DISTRIBUTION/PIPELINE WORKFLOW
- VIEWER IS USED IN LEARNING/EVOLUTION/SCENARIO WORKFLOW
- VIEWER IS UPDATED/USED IN SENSOR UPDATE WORKFLOW

*****************************************************************************************
VIEWER SHOULD BE GLOBALY REGISTERED AND UPDATED WITH SENSOR STATE BY SCHEDULE
*****************************************************************************************
*/

type IViewer interface {
}

type Viewer struct {
}

func (this *Viewer) GetMetrics() {

/*
- GET HEAT MAPS
- GET ACTIONS
- GET HABITS
- GET BEHAVIOURS
- ...
*/

}

func (this *Viewer) GetMetricsStats() {}

func (this *Viewer) GetMetricsForEntry() {

/*
- ENTRY METRICS/INDICES FOR SPECIFIC VIEWER
*/

}

func (this *Viewer) GetMetricsForFeed() {

/*
- FEED METRICS/INDICES FOR SPECIFIC VIEWER
*/

}

func (this *Viewer) GetGlobalIndicesForEntry() {

/*
- IT SHOULD BE A PROXY TO RESOURCE-API
- IT SHOUD GET ALL MINDICES FOR ENTRY
*/

}

func (this *Viewer) GetGlobalIndicesForFeed() {}

func (this *Viewer) GetStorages() {

/*
- GET ANNs BRAINS
- GET SVMs
- ...
*/

}

func (this *Viewer) GetCurrentContext() {

/*
- IP
- LOCATION
- BROWSER
- OS
- SENSORS
- WEATHER
- DAY PART
- BIORYTHM
- ...
*/

}

func (this *Viewer) GetEnvironment() {

/*
- SHOULD COMBINE
- CURRENT CONTEXT WITH...
- SENSORS WITH...
- METRICS...
*/

}
19 changes: 0 additions & 19 deletions plugin/rpc_data.go

This file was deleted.

47 changes: 47 additions & 0 deletions population/human.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package population

/*
IT DESCRIBE PERSON AS ENTITY OF PERSONALITY

IT HAS:
- HABITS
- ACTIONS
- BEHAVIOURS
- MOODS
- PHASES
- ...
*/

const (
HUMAN_SEX_FEMALE = 1
HUMAN_SEX_MALE = 2
)

type HumanController struct {
UID string

pvps map[string]*PVPController

sex int
}

func (this *HumanController) GetSex() int {
return this.sex
}

func (this *HumanController) SetSex(sex int) {
this.sex = sex
}

// experimental thinking...
func (this *HumanController) GetMoods() {}
func (this *HumanController) GetLActivityHours() {}

// SUPER SUPER GOAL: Private Virtual Personality
func (this *HumanController) GetNewPVP() *PVPController {
return NewPrivateVirtualPersonality()
}

func NewHumanController() *HumanController {
return &HumanController{"0", nil, 0}
}
Loading