From e716c747d2ed9a8b879648c672d478fd0726262c Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Mon, 22 Jun 2015 21:56:30 +0200 Subject: [PATCH 01/18] Update readme --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 055dbac..8887e39 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,15 @@ package by specifying the `TEST` variable. For example below, only #### Run -`go run api.go` +Environment variables +``` +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) From a7a0760dd38cf29c3d24462667634a6e8243bac8 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Mon, 22 Jun 2015 22:47:38 +0200 Subject: [PATCH 02/18] General tuning --- README.md | 2 +- common/config/general.go | 23 ++++++++++++++++++++++- conf/app.conf | 2 ++ plugin/manager.go | 4 ++-- workflow/workflow.go | 20 ++++++++++---------- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8887e39..ef29a3a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ package by specifying the `TEST` variable. For example below, only #### Run -Environment variables +Environment variables for plugins ``` export ELASTICFEED_PLUGIN_MIN_PORT=40000 export ELASTICFEED_PLUGIN_MAX_PORT=41000 diff --git a/common/config/general.go b/common/config/general.go index 8913fe6..d3d9577 100644 --- a/common/config/general.go +++ b/common/config/general.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "strconv" "github.com/feedlabs/feedify" ) @@ -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 @@ -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) diff --git a/conf/app.conf b/conf/app.conf index 6117fe7..cf69295 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -64,3 +64,5 @@ topic=feed [plugin-manager] storage=public/userfiles/plugin/imports +port_min=40000 +port_max=41000 diff --git a/plugin/manager.go b/plugin/manager.go index 6bd61c6..ae63e29 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -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 } diff --git a/workflow/workflow.go b/workflow/workflow.go index a53ea43..afbcbdc 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -1,7 +1,7 @@ package workflow import ( - "fmt" +// "fmt" "encoding/json" "time" @@ -74,8 +74,8 @@ func (this *WorkflowController) Init() { var rawTplInterface interface{} err := jsonutil.Unmarshal(data, &rawTplInterface) if err != nil { - fmt.Println(data) - fmt.Println(err) +// fmt.Println(data) +// fmt.Println(err) return } @@ -90,15 +90,15 @@ func (this *WorkflowController) Init() { decoder, err := mapstructure.NewDecoder(decoderConfig) if err != nil { - fmt.Println("err2") - fmt.Println(err) +// fmt.Println("err2") +// fmt.Println(err) return } err = decoder.Decode(rawTplInterface) if err != nil { - fmt.Println("err3") - fmt.Println(err) +// fmt.Println("err3") +// fmt.Println(err) return } @@ -108,9 +108,9 @@ func (this *WorkflowController) Init() { - PLUGINS SHOULD BE ABLE TO RUN FOR SPECIFIC WORKFLOW */ - fmt.Println(rawTpl) - fmt.Println(rawTpl.Storing.NewEntryEvent.Indexers[0]["type"]) - fmt.Println(rawTpl.Storing.NewEntryEvent.Crawlers[0]["type"]) +// fmt.Println(rawTpl) +// fmt.Println(rawTpl.Storing.NewEntryEvent.Indexers[0]["type"]) +// fmt.Println(rawTpl.Storing.NewEntryEvent.Crawlers[0]["type"]) } From 8501dde9f937a63538ff779df1f63f6aab02f59d Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 08:20:52 +0200 Subject: [PATCH 03/18] Updated app.conf --- conf/app.conf | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/conf/app.conf b/conf/app.conf index cf69295..0a774f1 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -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]) @@ -62,7 +73,3 @@ host=localhost port=1111 topic=feed -[plugin-manager] -storage=public/userfiles/plugin/imports -port_min=40000 -port_max=41000 From fc02e51222d6e0dc0b07ce266c51fdc66e18eafa Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 15:58:56 +0200 Subject: [PATCH 04/18] added plugin model for viewer --- plugin/model/viewer.go | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 plugin/model/viewer.go diff --git a/plugin/model/viewer.go b/plugin/model/viewer.go new file mode 100644 index 0000000..7d422f2 --- /dev/null +++ b/plugin/model/viewer.go @@ -0,0 +1,5 @@ +package model + +type Viewer interface { + +} From 7636e5f46fe8a8b2fa7b70ac489ab609fca1995b Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 16:13:03 +0200 Subject: [PATCH 05/18] Updated viewer model --- plugin/model/resource_api.go | 1 + plugin/model/viewer.go | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/plugin/model/resource_api.go b/plugin/model/resource_api.go index 6c90251..7234f5e 100644 --- a/plugin/model/resource_api.go +++ b/plugin/model/resource_api.go @@ -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() {} diff --git a/plugin/model/viewer.go b/plugin/model/viewer.go index 7d422f2..5633f22 100644 --- a/plugin/model/viewer.go +++ b/plugin/model/viewer.go @@ -1,5 +1,72 @@ package model +/* + TODO: + + - 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 Viewer interface { +} + +func (this *Viewer) GetMetrics() { + + /* + - GET HEAT MAPS + - GET ACTIONS + - GET HABITS + - GET BEHAVIOURS + - ... + */ + +} + +func (this *Viewer) GetMetricsStats() {} + +func (this *Viewer) GetMetricsForEntry() { + + /* + - ENTRY METRICS FOR SPECIFIC VIEWER + */ + +} + +func (this *Viewer) GetMetricsForFeed() { + + /* + - FEED METRICS FOR SPECIFIC VIEWER + */ + +} + +func (this *Viewer) GetStorages() { + + /* + - GET ANNs BRAINS + - GET SVMs + - ... + */ + +} + +func (this *Viewer) GetCurrentContext() { + + /* + - IP + - LOCATION + - BROWSER + - OS + - SENSORS + - WEATHER + - DAY PART + - BIORYTHM + - ... + */ } From e452e26737db868972f538f9d0aed4268ca0fcaa Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 16:19:59 +0200 Subject: [PATCH 06/18] extended viewer methods --- plugin/model/viewer.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin/model/viewer.go b/plugin/model/viewer.go index 5633f22..f29c1d2 100644 --- a/plugin/model/viewer.go +++ b/plugin/model/viewer.go @@ -32,7 +32,7 @@ func (this *Viewer) GetMetricsStats() {} func (this *Viewer) GetMetricsForEntry() { /* - - ENTRY METRICS FOR SPECIFIC VIEWER + - ENTRY METRICS/INDICES FOR SPECIFIC VIEWER */ } @@ -40,11 +40,22 @@ func (this *Viewer) GetMetricsForEntry() { func (this *Viewer) GetMetricsForFeed() { /* - - FEED METRICS FOR SPECIFIC VIEWER + - 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() { /* From 2782ae7699f1780585fe67cbf5ca9c9f62caa49a Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 16:24:18 +0200 Subject: [PATCH 07/18] VIEWER EXTENSIONS --- plugin/model/viewer.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugin/model/viewer.go b/plugin/model/viewer.go index f29c1d2..21608ff 100644 --- a/plugin/model/viewer.go +++ b/plugin/model/viewer.go @@ -81,3 +81,14 @@ func (this *Viewer) GetCurrentContext() { */ } + +func (this *Viewer) GetEnvironment() { + + /* + - SHOULD COMBINE + - CURRENT CONTEXT WITH... + - SENSORS WITH... + - METRICS... + */ + +} From e88799fc4e9b181d5f04c4bbf1239e42c2589080 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 19:22:21 +0200 Subject: [PATCH 08/18] Added population manager --- elasticfeed/elasticfeed.go | 8 ++++++++ elasticfeed/model/population.go | 6 ++++++ plugin/model/viewer.go | 11 ++++++++++- plugin/rpc_data.go | 19 ------------------- population/audience.go | 3 +++ population/manager.go | 19 +++++++++++++++++++ population/person.go | 17 +++++++++++++++++ 7 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 elasticfeed/model/population.go delete mode 100644 plugin/rpc_data.go create mode 100644 population/audience.go create mode 100644 population/manager.go create mode 100644 population/person.go diff --git a/elasticfeed/elasticfeed.go b/elasticfeed/elasticfeed.go index 5628668..a899969 100644 --- a/elasticfeed/elasticfeed.go +++ b/elasticfeed/elasticfeed.go @@ -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" ) @@ -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 { @@ -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 {}) } @@ -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() @@ -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 } diff --git a/elasticfeed/model/population.go b/elasticfeed/model/population.go new file mode 100644 index 0000000..f883e26 --- /dev/null +++ b/elasticfeed/model/population.go @@ -0,0 +1,6 @@ +package model + +type PopulationManager interface { + + Init() +} diff --git a/plugin/model/viewer.go b/plugin/model/viewer.go index 21608ff..d078b3c 100644 --- a/plugin/model/viewer.go +++ b/plugin/model/viewer.go @@ -3,6 +3,12 @@ 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 @@ -12,7 +18,10 @@ package model ***************************************************************************************** */ -type Viewer interface { +type IViewer interface { +} + +type Viewer struct { } func (this *Viewer) GetMetrics() { diff --git a/plugin/rpc_data.go b/plugin/rpc_data.go deleted file mode 100644 index 4af435e..0000000 --- a/plugin/rpc_data.go +++ /dev/null @@ -1,19 +0,0 @@ -package plugin - -import ( - "net/rpc" - "github.com/feedlabs/elasticfeed/plugin/model" -) - -// An implementation of packer.Cache where the RpcData is actually executed -// over an RPC connection. -type RpcData struct { - client *rpc.Client - endpoint string -} - -// CacheRpcServer wraps a packer.Cache implementation and makes it exportable -// as part of a Golang RPC server. -type DataRpcServer struct { - data model.Data -} diff --git a/population/audience.go b/population/audience.go new file mode 100644 index 0000000..94e931f --- /dev/null +++ b/population/audience.go @@ -0,0 +1,3 @@ +package population + +type AudienceController struct {} diff --git a/population/manager.go b/population/manager.go new file mode 100644 index 0000000..ff4a589 --- /dev/null +++ b/population/manager.go @@ -0,0 +1,19 @@ +package population + +import ( + emodel "github.com/feedlabs/elasticfeed/elasticfeed/model" +) + +type PopulationManager struct { + engine emodel.Elasticfeed + + people map[string]*PersonController +} + +func (this *PopulationManager) Init() { + this.people = make(map[string]*PersonController) +} + +func NewPopulationManager(engine emodel.Elasticfeed) *PopulationManager { + return &PopulationManager{engine, nil} +} diff --git a/population/person.go b/population/person.go new file mode 100644 index 0000000..ec38c90 --- /dev/null +++ b/population/person.go @@ -0,0 +1,17 @@ +package population + +/* + IT DESCRIBE PERSON AS ENTITY OF PERSONALITY + + IT HAS: + - HABITS + - ACTIONS + - BEHAVIOURS + - MOODS + - PHASES + - ... + */ + +type PersonController struct { + +} From 9f8795cbad23baf5681779f984f61b52618e2f8e Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 21:04:38 +0200 Subject: [PATCH 09/18] Renamed person with human and audience with society --- population/audience.go | 3 --- population/{person.go => human.go} | 2 +- population/manager.go | 4 ++-- population/society.go | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 population/audience.go rename population/{person.go => human.go} (82%) create mode 100644 population/society.go diff --git a/population/audience.go b/population/audience.go deleted file mode 100644 index 94e931f..0000000 --- a/population/audience.go +++ /dev/null @@ -1,3 +0,0 @@ -package population - -type AudienceController struct {} diff --git a/population/person.go b/population/human.go similarity index 82% rename from population/person.go rename to population/human.go index ec38c90..455a160 100644 --- a/population/person.go +++ b/population/human.go @@ -12,6 +12,6 @@ package population - ... */ -type PersonController struct { +type HumanController struct { } diff --git a/population/manager.go b/population/manager.go index ff4a589..08698b5 100644 --- a/population/manager.go +++ b/population/manager.go @@ -7,11 +7,11 @@ import ( type PopulationManager struct { engine emodel.Elasticfeed - people map[string]*PersonController + people map[string]*HumanController } func (this *PopulationManager) Init() { - this.people = make(map[string]*PersonController) + this.people = make(map[string]*HumanController) } func NewPopulationManager(engine emodel.Elasticfeed) *PopulationManager { diff --git a/population/society.go b/population/society.go new file mode 100644 index 0000000..ae273b0 --- /dev/null +++ b/population/society.go @@ -0,0 +1,3 @@ +package population + +type SocietyController struct {} From 665de279b119986a139df8ece8cacd2af7b03549 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 21:49:28 +0200 Subject: [PATCH 10/18] Naming, formatting... --- population/human.go | 17 +++++++++++++++++ population/manager.go | 1 + population/society.go | 12 +++++++++++- population/trait/location.go | 3 +++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 population/trait/location.go diff --git a/population/human.go b/population/human.go index 455a160..90aebaa 100644 --- a/population/human.go +++ b/population/human.go @@ -12,6 +12,23 @@ package population - ... */ +const ( + HUMAN_SEX_FEMALE = 1 + HUMAN_SEX_MALE = 2 +) + type HumanController struct { + sex int +} + +func (this *HumanController) GetSex() int { + return this.sex +} + +func (this *HumanController) SetSex(sex int) { + this.sex = sex +} +func NewHumanController() *HumanController { + return &HumanController{0} } diff --git a/population/manager.go b/population/manager.go index 08698b5..620e2c0 100644 --- a/population/manager.go +++ b/population/manager.go @@ -8,6 +8,7 @@ type PopulationManager struct { engine emodel.Elasticfeed people map[string]*HumanController + societies map[string]*SocietyController } func (this *PopulationManager) Init() { diff --git a/population/society.go b/population/society.go index ae273b0..54bd2c3 100644 --- a/population/society.go +++ b/population/society.go @@ -1,3 +1,13 @@ package population -type SocietyController struct {} +type SocietyController struct { + people map[string]*HumanController +} + +func (this *SocietyController) Init() { + this.people = make(map[string]*HumanController) +} + +func NewSocietyController() *SocietyController { + return &SocietyController{nil} +} diff --git a/population/trait/location.go b/population/trait/location.go new file mode 100644 index 0000000..aebd301 --- /dev/null +++ b/population/trait/location.go @@ -0,0 +1,3 @@ +package models + +type LocationController struct {} From f172cfa776f812e855230f4cac07c0fb469c40eb Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 21:50:32 +0200 Subject: [PATCH 11/18] Bugs... --- population/manager.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/population/manager.go b/population/manager.go index 620e2c0..65578ad 100644 --- a/population/manager.go +++ b/population/manager.go @@ -13,8 +13,9 @@ type PopulationManager struct { func (this *PopulationManager) Init() { this.people = make(map[string]*HumanController) + this.societies = make(map[string]*SocietyController) } func NewPopulationManager(engine emodel.Elasticfeed) *PopulationManager { - return &PopulationManager{engine, nil} + return &PopulationManager{engine, nil, nil} } From 706745d21fefeff8b74c58f61b5a4336711e38ec Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Tue, 23 Jun 2015 23:25:17 +0200 Subject: [PATCH 12/18] Extended WorkflowController with Subscribers/HumanController --- workflow/workflow.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/workflow/workflow.go b/workflow/workflow.go index afbcbdc..3c02817 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -9,6 +9,7 @@ import ( "github.com/feedlabs/elasticfeed/plugin/model" "github.com/feedlabs/elasticfeed/resource" + "github.com/feedlabs/elasticfeed/population" jsonutil "github.com/mitchellh/packer/common/json" "github.com/mitchellh/mapstructure" @@ -22,6 +23,8 @@ type WorkflowController struct { feed *resource.Feed manager *WorkflowManager + subscribers map[string]*population.HumanController + profiler *model.Profiler IndexerTimeout int @@ -74,8 +77,8 @@ func (this *WorkflowController) Init() { var rawTplInterface interface{} err := jsonutil.Unmarshal(data, &rawTplInterface) if err != nil { -// fmt.Println(data) -// fmt.Println(err) + // fmt.Println(data) + // fmt.Println(err) return } @@ -90,15 +93,15 @@ func (this *WorkflowController) Init() { decoder, err := mapstructure.NewDecoder(decoderConfig) if err != nil { -// fmt.Println("err2") -// fmt.Println(err) + // fmt.Println("err2") + // fmt.Println(err) return } err = decoder.Decode(rawTplInterface) if err != nil { -// fmt.Println("err3") -// fmt.Println(err) + // fmt.Println("err3") + // fmt.Println(err) return } @@ -108,9 +111,9 @@ func (this *WorkflowController) Init() { - PLUGINS SHOULD BE ABLE TO RUN FOR SPECIFIC WORKFLOW */ -// fmt.Println(rawTpl) -// fmt.Println(rawTpl.Storing.NewEntryEvent.Indexers[0]["type"]) -// fmt.Println(rawTpl.Storing.NewEntryEvent.Crawlers[0]["type"]) + // fmt.Println(rawTpl) + // fmt.Println(rawTpl.Storing.NewEntryEvent.Indexers[0]["type"]) + // fmt.Println(rawTpl.Storing.NewEntryEvent.Crawlers[0]["type"]) } @@ -230,9 +233,11 @@ func (this *WorkflowController) ExecutePipelineChain(socketEvent smodel.SocketEv } func NewWorkflowController(feed *resource.Feed, wm *WorkflowManager) *WorkflowController { + subscribers := make(map[string]*population.HumanController) + data := feed.GetWorkflow().GetProfilerRawData() p := model.NewProfiler(data) - w := &WorkflowController{feed, wm, p, 100, 100, 100, 50, 100} + w := &WorkflowController{feed, wm, subscribers, p, 100, 100, 100, 50, 100} w.Init() From 3018b710ced79307a0dad927c62f93f8ab99c4a2 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 09:11:59 +0200 Subject: [PATCH 13/18] Extended workflow controller and human controller --- population/human.go | 4 +++- workflow/workflow.go | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/population/human.go b/population/human.go index 90aebaa..80c086e 100644 --- a/population/human.go +++ b/population/human.go @@ -18,6 +18,8 @@ const ( ) type HumanController struct { + UID string + sex int } @@ -30,5 +32,5 @@ func (this *HumanController) SetSex(sex int) { } func NewHumanController() *HumanController { - return &HumanController{0} + return &HumanController{"0", 0} } diff --git a/workflow/workflow.go b/workflow/workflow.go index 3c02817..5ee9944 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -19,6 +19,15 @@ import ( "github.com/feedlabs/elasticfeed/service/stream/controller/room" ) +/* + WORKFLOW CONTROLLER SHOULD + - REGISTER FEED WORKFLOW + - SHOULD STORE SUBSCRIBED HUMANS/VIEWERS + - SHOULD BE ABLE TO READ/WRTIE METRICS/INDICES/STORAGES + - SHOULD BE ABLE TO ACCESS SENSORS STATUS FOR SPECIFIC WORKFLOW + + */ + type WorkflowController struct { feed *resource.Feed manager *WorkflowManager @@ -232,6 +241,18 @@ func (this *WorkflowController) ExecutePipelineChain(socketEvent smodel.SocketEv } } +func (this * WorkflowController) GetHumanByUID(uid string) *population.HumanController { + return this.subscribers[uid] +} + +func (this * WorkflowController) RegisterHuman(human *population.HumanController) { + this.subscribers[human.UID] = human +} + +func (this * WorkflowController) UnregisterHuman(human *population.HumanController) { + delete(this.subscribers, human.UID) +} + func NewWorkflowController(feed *resource.Feed, wm *WorkflowManager) *WorkflowController { subscribers := make(map[string]*population.HumanController) From 24795ab527e38da6ef6a47460fefa7cc3f6f9e0a Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 11:08:02 +0200 Subject: [PATCH 14/18] Introduced Private Virtual Personality --- population/human.go | 43 +++++++++++++++++++++++++++++++++++++++++++ population/pvp.go | 20 ++++++++++++++++++++ workflow/workflow.go | 12 ++++++------ 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 population/pvp.go diff --git a/population/human.go b/population/human.go index 80c086e..8ea7355 100644 --- a/population/human.go +++ b/population/human.go @@ -31,6 +31,49 @@ 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) GetPVP() *PVPControler { + + /* + - SHOULD LEARN FROM HUMAN + - SHOULD ADVISE HUMAN + - SHOULD TEACH HUMAN + */ + + return NewPrivateVirtualPersonality() +} + +// SUPER GOAL: Artificial Intelligence +func (this *HumanController) GetAI() { + /* + SHOULD IMPLEMENT BRIDGE TO AI FRAMEWORK + - SHOULD ALLOW TO REGISTER BRAINS + - SHOULD ALLOW TO TRAIN/FORWARD OVER BRAINS + - SHOULD ALLOW FOR EVOLVING + - SHOULD ALLOW FOR GENETIC ALGORITHMS + - SHOULD ALLOW FOR SIMPLE SVM + - SHOULD ALLOW FOR ANY KIND OF AI + + ******************************************** + LOOKS LIKE IMPORTANT PART + IT WILL BE THE GOAL OF ELASTICFEED + TO MAKE IT WORKING. + + THE COMBINATION OF: + - TRAINING USING CURRENT SENSORS + - CURRENT BRAIN STATE + - CURRENT INDICES + - CURRENT METRICS OF ACTIONS, BEHAVIOURS + - CURRENT HABITS + - ... + ******************************************** + */ +} + func NewHumanController() *HumanController { return &HumanController{"0", 0} } diff --git a/population/pvp.go b/population/pvp.go new file mode 100644 index 0000000..bb41b1f --- /dev/null +++ b/population/pvp.go @@ -0,0 +1,20 @@ +package population + +/* + + Private Virtual Personality + + https://en.wikipedia.org/wiki/Talk%3APrivate_virtual_personality + + VI vs AI + + A VI is restricted to certain responses and actions, and can't become self-aware, + while an AI is free to think how it likes and is self-aware. + + */ + +type PVPControler struct {} + +func NewPrivateVirtualPersonality() *PVPControler { + return &PVPControler{} +} diff --git a/workflow/workflow.go b/workflow/workflow.go index 5ee9944..bee0cad 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -32,7 +32,7 @@ type WorkflowController struct { feed *resource.Feed manager *WorkflowManager - subscribers map[string]*population.HumanController + population map[string]*population.HumanController profiler *model.Profiler @@ -242,23 +242,23 @@ func (this *WorkflowController) ExecutePipelineChain(socketEvent smodel.SocketEv } func (this * WorkflowController) GetHumanByUID(uid string) *population.HumanController { - return this.subscribers[uid] + return this.population[uid] } func (this * WorkflowController) RegisterHuman(human *population.HumanController) { - this.subscribers[human.UID] = human + this.population[human.UID] = human } func (this * WorkflowController) UnregisterHuman(human *population.HumanController) { - delete(this.subscribers, human.UID) + delete(this.population, human.UID) } func NewWorkflowController(feed *resource.Feed, wm *WorkflowManager) *WorkflowController { - subscribers := make(map[string]*population.HumanController) + population := make(map[string]*population.HumanController) data := feed.GetWorkflow().GetProfilerRawData() p := model.NewProfiler(data) - w := &WorkflowController{feed, wm, subscribers, p, 100, 100, 100, 50, 100} + w := &WorkflowController{feed, wm, population, p, 100, 100, 100, 50, 100} w.Init() From ff9455c80883d57c675fe2a10e17317e6a6e1d8c Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 11:14:19 +0200 Subject: [PATCH 15/18] Moved AI logic into PVP --- population/human.go | 33 ++++----------------------------- population/pvp.go | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/population/human.go b/population/human.go index 8ea7355..f4cd562 100644 --- a/population/human.go +++ b/population/human.go @@ -20,6 +20,8 @@ const ( type HumanController struct { UID string + pvps map[string]*PVPControler + sex int } @@ -36,7 +38,7 @@ func (this *HumanController) GetMoods() {} func (this *HumanController) GetLActivityHours() {} // SUPER SUPER GOAL: Private Virtual Personality -func (this *HumanController) GetPVP() *PVPControler { +func (this *HumanController) GetNewPVP() *PVPControler { /* - SHOULD LEARN FROM HUMAN @@ -47,33 +49,6 @@ func (this *HumanController) GetPVP() *PVPControler { return NewPrivateVirtualPersonality() } -// SUPER GOAL: Artificial Intelligence -func (this *HumanController) GetAI() { - /* - SHOULD IMPLEMENT BRIDGE TO AI FRAMEWORK - - SHOULD ALLOW TO REGISTER BRAINS - - SHOULD ALLOW TO TRAIN/FORWARD OVER BRAINS - - SHOULD ALLOW FOR EVOLVING - - SHOULD ALLOW FOR GENETIC ALGORITHMS - - SHOULD ALLOW FOR SIMPLE SVM - - SHOULD ALLOW FOR ANY KIND OF AI - - ******************************************** - LOOKS LIKE IMPORTANT PART - IT WILL BE THE GOAL OF ELASTICFEED - TO MAKE IT WORKING. - - THE COMBINATION OF: - - TRAINING USING CURRENT SENSORS - - CURRENT BRAIN STATE - - CURRENT INDICES - - CURRENT METRICS OF ACTIONS, BEHAVIOURS - - CURRENT HABITS - - ... - ******************************************** - */ -} - func NewHumanController() *HumanController { - return &HumanController{"0", 0} + return &HumanController{"0", nil, 0} } diff --git a/population/pvp.go b/population/pvp.go index bb41b1f..1ddaeea 100644 --- a/population/pvp.go +++ b/population/pvp.go @@ -15,6 +15,33 @@ package population type PVPControler struct {} +// SUPER GOAL: Artificial Intelligence +func (this *PVPControler) GetAI() { + /* + SHOULD IMPLEMENT BRIDGE TO AI FRAMEWORK + - SHOULD ALLOW TO REGISTER BRAINS + - SHOULD ALLOW TO TRAIN/FORWARD OVER BRAINS + - SHOULD ALLOW FOR EVOLVING + - SHOULD ALLOW FOR GENETIC ALGORITHMS + - SHOULD ALLOW FOR SIMPLE SVM + - SHOULD ALLOW FOR ANY KIND OF AI + + ******************************************** + LOOKS LIKE IMPORTANT PART + IT WILL BE THE GOAL OF ELASTICFEED + TO MAKE IT WORKING. + + THE COMBINATION OF: + - TRAINING USING CURRENT SENSORS + - CURRENT BRAIN STATE + - CURRENT INDICES + - CURRENT METRICS OF ACTIONS, BEHAVIOURS + - CURRENT HABITS + - ... + ******************************************** + */ +} + func NewPrivateVirtualPersonality() *PVPControler { return &PVPControler{} } From d8a139a485b8507675f9eff1575e07686c181709 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 11:21:27 +0200 Subject: [PATCH 16/18] Formatting --- population/human.go | 7 ------- population/pvp.go | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/population/human.go b/population/human.go index f4cd562..759d3a1 100644 --- a/population/human.go +++ b/population/human.go @@ -39,13 +39,6 @@ func (this *HumanController) GetLActivityHours() {} // SUPER SUPER GOAL: Private Virtual Personality func (this *HumanController) GetNewPVP() *PVPControler { - - /* - - SHOULD LEARN FROM HUMAN - - SHOULD ADVISE HUMAN - - SHOULD TEACH HUMAN - */ - return NewPrivateVirtualPersonality() } diff --git a/population/pvp.go b/population/pvp.go index 1ddaeea..75e877b 100644 --- a/population/pvp.go +++ b/population/pvp.go @@ -1,8 +1,9 @@ package population /* - - Private Virtual Personality + *********************************** + * Private Virtual Personality * + *********************************** https://en.wikipedia.org/wiki/Talk%3APrivate_virtual_personality @@ -13,7 +14,16 @@ package population */ -type PVPControler struct {} +type PVPControler struct { + + /* + - SHOULD LEARNs FROM HUMAN + - SHOULD SERVEs HUMAN + - SHOULD ADVISEs HUMAN + - SHOULD TEACHes HUMAN + */ + +} // SUPER GOAL: Artificial Intelligence func (this *PVPControler) GetAI() { From c3f546028d13184ec383911a023e586435ef3b76 Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 17:49:59 +0200 Subject: [PATCH 17/18] - added pupulation traits - commented PVP --- population/pvp.go | 5 +++++ population/trait/behaviour.go | 3 +++ population/trait/decision.go | 3 +++ population/trait/fact.go | 3 +++ population/trait/habit.go | 3 +++ population/trait/location.go | 2 +- population/trait/mood.go | 3 +++ 7 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 population/trait/behaviour.go create mode 100644 population/trait/decision.go create mode 100644 population/trait/fact.go create mode 100644 population/trait/habit.go create mode 100644 population/trait/mood.go diff --git a/population/pvp.go b/population/pvp.go index 75e877b..6417390 100644 --- a/population/pvp.go +++ b/population/pvp.go @@ -17,10 +17,15 @@ package population type PVPControler struct { /* + Basic: - SHOULD LEARNs FROM HUMAN - SHOULD SERVEs HUMAN - SHOULD ADVISEs HUMAN - SHOULD TEACHes HUMAN + + Advnaced: + - SHOULD TALK TO OTHER PVPs + - SHOULD ANSWER QUESTIONS */ } diff --git a/population/trait/behaviour.go b/population/trait/behaviour.go new file mode 100644 index 0000000..d8a3c89 --- /dev/null +++ b/population/trait/behaviour.go @@ -0,0 +1,3 @@ +package trait + +type BehaviourController struct {} diff --git a/population/trait/decision.go b/population/trait/decision.go new file mode 100644 index 0000000..a4aebc0 --- /dev/null +++ b/population/trait/decision.go @@ -0,0 +1,3 @@ +package trait + +type DecisionController struct {} diff --git a/population/trait/fact.go b/population/trait/fact.go new file mode 100644 index 0000000..5b5e940 --- /dev/null +++ b/population/trait/fact.go @@ -0,0 +1,3 @@ +package trait + +type FactController struct {} diff --git a/population/trait/habit.go b/population/trait/habit.go new file mode 100644 index 0000000..1c741a5 --- /dev/null +++ b/population/trait/habit.go @@ -0,0 +1,3 @@ +package trait + +type HabitController struct {} diff --git a/population/trait/location.go b/population/trait/location.go index aebd301..2af8c28 100644 --- a/population/trait/location.go +++ b/population/trait/location.go @@ -1,3 +1,3 @@ -package models +package trait type LocationController struct {} diff --git a/population/trait/mood.go b/population/trait/mood.go new file mode 100644 index 0000000..2334cfa --- /dev/null +++ b/population/trait/mood.go @@ -0,0 +1,3 @@ +package trait + +type MoodController struct {} From f4263825c4dbc189d3322e934c12317ed5caee4f Mon Sep 17 00:00:00 2001 From: Chris Stasiak Date: Wed, 24 Jun 2015 18:26:30 +0200 Subject: [PATCH 18/18] COMMENTED PVP METHODS --- population/human.go | 4 ++-- population/pvp.go | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/population/human.go b/population/human.go index 759d3a1..236c298 100644 --- a/population/human.go +++ b/population/human.go @@ -20,7 +20,7 @@ const ( type HumanController struct { UID string - pvps map[string]*PVPControler + pvps map[string]*PVPController sex int } @@ -38,7 +38,7 @@ func (this *HumanController) GetMoods() {} func (this *HumanController) GetLActivityHours() {} // SUPER SUPER GOAL: Private Virtual Personality -func (this *HumanController) GetNewPVP() *PVPControler { +func (this *HumanController) GetNewPVP() *PVPController { return NewPrivateVirtualPersonality() } diff --git a/population/pvp.go b/population/pvp.go index 6417390..d4ba3ae 100644 --- a/population/pvp.go +++ b/population/pvp.go @@ -14,7 +14,7 @@ package population */ -type PVPControler struct { +type PVPController struct { /* Basic: @@ -26,12 +26,39 @@ type PVPControler struct { Advnaced: - SHOULD TALK TO OTHER PVPs - SHOULD ANSWER QUESTIONS + + Intelligence: + - Intelligence Quotient (IQ) + - Emotional Intelligence (EI) + */ + +} + +func (this *PVPController) Train() { + /* + PVP LEARNS VIA HUMAN TEACHING + - CARROT/STICK METHOD + - MOOD DETECTION + - ... */ +} + +func (this *PVPController) Query() { + /* + QUESTION WITH LOGIC ANSWER: YES/NO + + QUESTION WITH PROBABILITY ANSWER: MAYBE YES, MAYBE NOT + QUESTION ABOUT LIKENESS OF SUBJECT: LIKE/DISLIKE + + QUESTION ABOUT LIKENESS OF PRICE: LIKE/DISLIKE + + QUESTION ABOUT MOOD: GOOD, BAD, SAD + */ } // SUPER GOAL: Artificial Intelligence -func (this *PVPControler) GetAI() { +func (this *PVPController) GetAI() { /* SHOULD IMPLEMENT BRIDGE TO AI FRAMEWORK - SHOULD ALLOW TO REGISTER BRAINS @@ -57,6 +84,6 @@ func (this *PVPControler) GetAI() { */ } -func NewPrivateVirtualPersonality() *PVPControler { - return &PVPControler{} +func NewPrivateVirtualPersonality() *PVPController { + return &PVPController{} }