Permalink
Browse files

Merge pull request #7 from djdeath/new-port-api

Update components to new port api
  • Loading branch information...
2 parents 9876302 + eccd81d commit 84d2369ebe9c58f30f65edbc2076c1c0f2e78eac @bergie bergie committed May 16, 2014
@@ -10,11 +10,17 @@ class CollectGroups extends noflo.Component
# Breadcrumb of each level of IPs as partitioned by groups
@parents = []
- @inPorts =
- in: new noflo.Port 'all'
- @outPorts =
- out: new noflo.Port 'object'
- error: new noflo.Port 'object'
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to collect'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'object'
+ description: 'An object containing input IPs sorted by their group
+ names'
+ error:
+ datatype: 'object'
@inPorts.in.on 'connect', =>
# Make sure working memory is clean
@@ -10,14 +10,20 @@ class CollectObject extends noflo.Component
@data = {}
@groups = {}
- @inPorts =
- keys: new noflo.ArrayPort 'string'
- allpackets: new noflo.ArrayPort 'string'
- collect: new noflo.ArrayPort 'all'
- release: new noflo.Port 'bang'
- clear: new noflo.Port 'bang'
- @outPorts =
- out: new noflo.Port 'object'
+ @inPorts = new noflo.InPorts
+ keys:
+ datatype: 'string'
+ allpackets:
+ datatype: 'string'
+ collect:
+ datatype: 'all'
+ release:
+ datatype: 'bang'
+ clear:
+ datatype: 'bang'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'object'
@inPorts.keys.on 'data', (key) =>
keys = key.split ','
@@ -7,11 +7,14 @@ class CollectTree extends noflo.Component
constructor: ->
@data = null
@groups = []
- @inPorts =
- in: new noflo.Port 'all'
- @outPorts =
- out: new noflo.Port 'all'
- error: new noflo.Port 'object'
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
+ error:
+ datatype: 'object'
@inPorts.in.on 'connect', =>
@data = {}
@@ -10,13 +10,20 @@ class FilterByGroup extends noflo.Component
@regexp = null
@matchedLevel = null
- @inPorts =
- in: new noflo.Port
- regexp: new noflo.Port
- @outPorts =
- out: new noflo.Port
- group: new noflo.Port
- empty: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to filter groups from'
+ regexp:
+ datatype: 'string'
+ description: 'Regexp use as a filter for IPs'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
+ group:
+ datatype: 'string'
+ empty:
+ datatype: 'bang'
@inPorts.regexp.on "data", (regexp) =>
@regexp = new RegExp(regexp)
@@ -1,13 +1,17 @@
noflo = require 'noflo'
class FirstGroup extends noflo.Component
+ description: 'Forward incoming IPs and filter groups except the first one'
constructor: ->
@depth = 0
- @inPorts =
- in: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to forward'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.in.on 'begingroup', (group) =>
@outPorts.out.beginGroup group if @depth is 0
@@ -6,10 +6,13 @@ class GenerateGroup extends noflo.Component
description: 'Wrap IPs into a random uuid generated group'
constructor: ->
- @inPorts =
- in: new noflo.Port 'all'
- @outPorts =
- out: new noflo.Port 'all'
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to forward'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@groups = []
View
@@ -5,12 +5,20 @@ class Group extends noflo.Component
constructor: ->
@newGroups = []
- @inPorts =
- in: new noflo.Port 'all'
- group: new noflo.Port 'string'
- clear: new noflo.Port 'bang'
- @outPorts =
- out: new noflo.Port 'all'
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to forward'
+ group:
+ datatype: 'string'
+ description: 'Groups to encapsulate incoming packets into'
+ clear:
+ datatype: 'bang'
+ description: 'Clear encapsulating groups'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
+ description: 'Forwarded IPs with encapsulating groups'
@inPorts.in.on "connect", () =>
@outPorts.out.beginGroup group for group in @newGroups
@@ -5,11 +5,14 @@ class GroupByObjectKey extends noflo.Component
@data = []
@key = null
- @inPorts =
- in: new noflo.Port()
- key: new noflo.Port()
- @outPorts =
- out: new noflo.Port()
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ key:
+ datatype: 'string'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.in.on 'connect', =>
@data = []
@@ -25,7 +28,7 @@ class GroupByObjectKey extends noflo.Component
# Data already sent
@outPorts.out.disconnect()
return
-
+
# No key, data will be sent when we get it
return unless @key
View
@@ -4,11 +4,14 @@ class GroupZip extends noflo.Component
constructor: ->
@newGroups = []
- @inPorts =
- in: new noflo.Port
- group: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ group:
+ datatype: 'string'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.in.on "connect", () =>
@count = 0
@@ -1,11 +1,16 @@
noflo = require 'noflo'
class LastGroup extends noflo.Component
+ description: 'Forward packets wrapped only using the latest emitted
+ group'
constructor: ->
- @inPorts =
- in: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to forward'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@groups = []
@groupSent = 0
View
@@ -5,12 +5,16 @@ class MapGroup extends noflo.Component
@map = {}
@regexps = {}
- @inPorts =
- map: new noflo.ArrayPort()
- regexp: new noflo.ArrayPort()
- in: new noflo.Port()
- @outPorts =
- out: new noflo.Port()
+ @inPorts = new noflo.InPorts
+ map:
+ datatype: 'all'
+ regexp:
+ datatype: 'all'
+ in:
+ datatype: 'all'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.map.on 'data', (data) =>
@prepareMap data
@@ -5,10 +5,12 @@ class MergeGroups extends noflo.Component
constructor: ->
@groups = {}
@data = {}
- @inPorts =
- in: new noflo.ArrayPort
- @outPorts =
- out: new noflo.ArrayPort
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.in.on 'begingroup', (group, socket) =>
@addGroup socket, group
@@ -10,11 +10,14 @@ class Objectify extends noflo.Component
@regexp = null
@match = null
- @inPorts =
- in: new noflo.Port
- regexp: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ regexp:
+ datatype: 'string'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.regexp.on "data", (regexp) =>
@regexp = new RegExp(regexp)
@@ -4,11 +4,14 @@ class ReadGroup extends noflo.Component
constructor: ->
@groups = []
- @inPorts =
- in: new noflo.ArrayPort
- @outPorts =
- out: new noflo.Port
- group: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
+ group:
+ datatype: 'string'
@inPorts.in.on 'begingroup', (group) =>
@groups.push group
@@ -6,13 +6,18 @@ class ReadGroups extends noflo.Component
@strip = false
@threshold = Infinity
- @inPorts =
- in: new noflo.ArrayPort
- strip: new noflo.Port
- threshold: new noflo.Port
- @outPorts =
- out: new noflo.Port
- group: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ strip:
+ datatype: 'string'
+ threshold:
+ datatype: 'all'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
+ group:
+ datatype: 'string'
@inPorts.threshold.on 'data', (threshold) =>
@threshold = parseInt threshold
View
@@ -8,11 +8,14 @@ class Regroup extends noflo.Component
constructor: ->
@groups = []
- @inPorts =
- in: new noflo.Port
- group: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ group:
+ datatype: ''
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.group.on "connect", =>
@groups = []
@@ -7,11 +7,16 @@ class RemoveGroups extends noflo.Component
constructor: ->
@regexp = null
- @inPorts =
- in: new noflo.Port
- regexp: new noflo.Port
- @outPorts =
- out: new noflo.Port
+ @inPorts = new noflo.InPorts
+ in:
+ datatype: 'all'
+ description: 'IPs to forward'
+ regexp:
+ datatype: 'string'
+ description: 'Regexp used to remove groups'
+ @outPorts = new noflo.OutPorts
+ out:
+ datatype: 'all'
@inPorts.regexp.on "data", (regexp) =>
@regexp = new RegExp(regexp)
Oops, something went wrong.

0 comments on commit 84d2369

Please sign in to comment.