Skip to content

Commit

Permalink
added Google Protobuf files for Akka.CQRS (#9)
Browse files Browse the repository at this point in the history
* added Google Protobuf files for Akka.CQRS

* Added compiled protobuf output

* working on subscription messages

* added protobuf messages for pricing

* working on implementing TradeEventSerializer

* added TradeEventSerializer

* completed first pass at TradeEventSerializer

* Added tests to validate Protobuf usage
  • Loading branch information
Aaronontheweb authored May 23, 2019
1 parent 51234e7 commit d2c32a5
Show file tree
Hide file tree
Showing 21 changed files with 3,498 additions and 57 deletions.
32 changes: 32 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,38 @@ Target "NBench" <| fun _ ->

projects |> Seq.iter runSingleProject

//--------------------------------------------------------------------------------
// Serialization
//--------------------------------------------------------------------------------
Target "Protobuf" <| fun _ ->

let protocPath =
if isWindows then findToolInSubPath "protoc.exe" "tools/Google.Protobuf.Tools/tools/windows_x64"
elif isMacOS then findToolInSubPath "protoc" "tools/Google.Protobuf.Tools/tools/macosx_x64"
else findToolInSubPath "protoc" "tools/Google.Protobuf.Tools/tools/linux_x64"

let protoFiles = [
("Akka.Cqrs.proto", "/src/Akka.CQRS/Serialization/Proto/")
("Akka.Cqrs.Pricing.proto", "/src/Akka.CQRS.Pricing/Serialization/Proto") ]

printfn "Using proto.exe: %s" protocPath

let runProtobuf assembly =
let protoName, destinationPath = assembly
let args = StringBuilder()
|> append (sprintf "-I=%s" (__SOURCE_DIRECTORY__ @@ "/src/protobuf/") )
|> append (sprintf "--csharp_out=internal_access:%s" (__SOURCE_DIRECTORY__ @@ destinationPath))
|> append "--csharp_opt=file_extension=.g.cs"
|> append (__SOURCE_DIRECTORY__ @@ "/src/protobuf" @@ protoName)
|> toText

let result = ExecProcess(fun info ->
info.FileName <- protocPath
info.WorkingDirectory <- (Path.GetDirectoryName (FullName protocPath))
info.Arguments <- args) (System.TimeSpan.FromMinutes 45.0) (* Reasonably long-running task. *)
if result <> 0 then failwithf "protoc failed. %s %s" protocPath args

protoFiles |> Seq.iter (runProtobuf)

//--------------------------------------------------------------------------------
// Code signing targets
Expand Down
14 changes: 14 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ if (!(Test-Path $DocfxExePath)) {
}
}

###########################################################################
# Google.Protobuf.Tools
###########################################################################

# Make sure Google.Protobuf.Tools has been installed.
$ProtobufExePath = Join-Path $ToolPath "Google.Protobuf.Tools/tools/windows_x64/protoc.exe"
if (!(Test-Path $ProtobufExePath)) {
Write-Host "Installing Google.Protobuf.Tools..."
Invoke-Expression "&`"$NugetPath`" install Google.Protobuf.Tools -ExcludeVersion -Version $ProtobufVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring Google.Protobuf.Tools from NuGet."
}
}

###########################################################################
# SignTool
###########################################################################
Expand Down
36 changes: 0 additions & 36 deletions src/Akka.CQRS.Pricing/Commands/GetPriceHistory.cs

This file was deleted.

Loading

0 comments on commit d2c32a5

Please sign in to comment.