View send_to_logstash.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import json | |
import sys | |
HOST = 'logging.developmentci.rebb.baseless.nl' | |
PORT = 1514 | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
except socket.error, msg: |
View updatescript.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import json | |
import sys | |
HOST = 'logging.developmentci.rebb.baseless.nl' | |
#HOST = '127.0.0.1' | |
PORT = 1514 | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
View eventstream.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Message and event classes | |
case class UpdateAccountBalance(userId:Long, amount:Long) | |
case class BalanceUpdated(userId:Long) | |
//Actor that performs account updates | |
class AccountManager extends Actor{ | |
val dao = new AccountManagerDao | |
def receive = { | |
case UpdateAccountBalance(userId, amount) => |
View coalesce.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def coalesce(x:List[String], y:List[Int]):List[(String, Int)] = | |
(x zip y).groupBy(_._1) | |
.values | |
.map{_.reduce((i,j) => (i._1, (i._2 + j._2)))} | |
.toList | |
.sorted | |
View main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val oDataQuery: PackratParser[SourceNode]={ | |
serviceURL ~ resourcePath ~ opt(queryOperationDef) ^^ { | |
case uri ~ path ~ None => ODataQuery(uri, path, QueryOperations(Seq.empty)) | |
case uri ~ path ~ Some(exp) => ODataQuery(uri, path,QueryOperations(exp)) | |
} | |
} |
View expressionTree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ODataQuery( | |
URL("http://odata.io/odata.svc"), | |
ResourcePath("Schema",Number("231"),ResourcePath("Customer",EmptyExp(),EmptyExp())), | |
QueryOperations( | |
List(Top(Number("2")), | |
Filter( | |
EqualToExp( | |
CallExp( | |
Property("concat") | |
, List(Property("City"), Property("Country")) |
View ODataUriParserTests_Select.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Parse /Products?$select=Name"){ | |
val uri = "http://services.odata.org/OData.svc/Products?$select=Name,Price" | |
val actual = p.parseThis(mainParser,uri).get | |
val expectedAst = | |
ODataQuery( | |
URL("http://services.odata.org/OData.svc"), | |
ResourcePath("Products",EmptyExp(),EmptyExp()), | |
QueryOperations(List(Select(List(Property("Name"), Property("Price")))))) |
View ExpressionParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val expression: PackratParser[Expression] = | |
expression ~ ("add" ~> termExpression) ^^ {case l ~ r => PlusExp(l, r)} | | |
expression ~ ("sub" ~> termExpression) ^^ {case l ~ r => MinusExp(l, r)} | | |
termExpression | |
lazy val termExpression: PackratParser[Expression] = | |
termExpression ~ ("mul" ~> factor) ^^ {case a ~ b => MultiplyExp(a, b)} | | |
termExpression ~ ("div" ~> factor) ^^ {case a ~ b => DivideExp(a, b)} | | |
termExpression ~ ("mod" ~> factor) ^^ {case a ~ b => ModExp(a, b)} | | |
factor |
View resourcePath.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val resourcePath: PackratParser[Expression] =( | |
"/" ~> idn ~ ("(" ~> predicate <~ ")") ~ opt(resourcePath) ^^ { | |
case Property(name) ~ keyPredicate ~ None => ResourcePath(name, keyPredicate, EmptyExp()) | |
case Property(name) ~ keyPredicate ~ Some(expr) => ResourcePath(name, keyPredicate, expr) | |
} | |
| "/" ~> idn~ opt(resourcePath) ^^ { | |
case Property(e)~None => ResourcePath(e, EmptyExp(), EmptyExp()) | |
case Property(e)~Some(expr) => ResourcePath(e, EmptyExp(), expr) | |
} | |
) |
View ODataUriParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Parse /Customers?$top=2&$filter=concat(City, Country) eq 'Berlin, Germany'"){ | |
val uri = "http://odata.io/odata.svc/Schema(231)/Customer?$top=2&$filter=concat(City, Country) eq 'Berlin, Germany'" | |
val actual = p.parseThis(mainParser,uri).get | |
println(uri + "=>" + actual) | |
val expectedAst= | |
ODataQuery( | |
URL("http://odata.io/odata.svc"), | |
ResourcePath("Schema",Number("231"),ResourcePath("Customer",EmptyExp(),EmptyExp())), | |
QueryOperations( |
OlderNewer