Skip to content

Commit

Permalink
message storage using postgresql/s3
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindar committed Nov 1, 2016
1 parent 52a032f commit e5e8ca6
Show file tree
Hide file tree
Showing 25 changed files with 1,489 additions and 171 deletions.
18 changes: 18 additions & 0 deletions Emitter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Emitter.Runtime", "src\Emit
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Emitter.Server", "src\Emitter.Server\Emitter.Server.xproj", "{A7B5A40C-161B-47F1-9628-8D6B2CD09915}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Emitter.Storage.S3", "src\Emitter.Storage.S3\Emitter.Storage.S3.xproj", "{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,6 +53,22 @@ Global
{A7B5A40C-161B-47F1-9628-8D6B2CD09915}.Release|Win32.Build.0 = Release|Any CPU
{A7B5A40C-161B-47F1-9628-8D6B2CD09915}.Release|x64.ActiveCfg = Release|Any CPU
{A7B5A40C-161B-47F1-9628-8D6B2CD09915}.Release|x64.Build.0 = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|Win32.Build.0 = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|x64.ActiveCfg = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Debug|x64.Build.0 = Debug|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Any CPU.Build.0 = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Win32.ActiveCfg = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|Win32.Build.0 = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|x64.ActiveCfg = Release|Any CPU
{4BB2CC21-E570-4951-96DC-6D8EF05D19BA}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ assembly_info:

before_build:
- cmd: >-
dotnet restore src\Emitter.Server && dotnet restore src\Emitter.Runtime
dotnet restore src\Emitter.Server && dotnet restore src\Emitter.Runtime && dotnet restore src\Emitter.Storage.S3
cd build && npm install && node add-project-version.js && cd..
build_script:
- cmd: >-
dotnet pack src\Emitter.Runtime --configuration Release --output "Emitter" && dotnet pack src\Emitter.Server --configuration Release --output "Emitter"
dotnet pack src\Emitter.Runtime --configuration Release --output "Emitter" && dotnet pack src\Emitter.Storage.S3 --configuration Release --output "Emitter" && dotnet pack src\Emitter.Server --configuration Release --output "Emitter"
test: off

artifacts:
Expand Down
1 change: 1 addition & 0 deletions build/add-project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var semversion = semver.valid(basePackageVer + "-dev" + buildNumber);
// Set version on several projects
setVersion("../src/emitter.runtime/project.json");
setVersion("../src/emitter.server/project.json");
setVersion("../src/emitter.storage.s3/project.json");

/**
* Set the version on the particular file.
Expand Down
11 changes: 7 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ MAINTAINER Roman Atachiants "roman@misakai.com"

# Make sure we have S3 & additional libraries
RUN apt-get update -qq \
&& apt-get install -y s3cmd git wget \
&& git clone "https://github.com/emitter-io/emitter.git" "/app" \
&& cd /app \
&& dotnet restore -v Minimal
&& apt-get install -y git \
&& mkdir /tmp/emitter \
&& cd /tmp/emitter \
&& git clone "https://github.com/emitter-io/emitter.git" "/tmp/emitter" \
&& cd /tmp/emitter/src/Emitter.Server \
&& dotnet publish -c Release --output /app \
&& rm -rf /tmp/emitter

# Application will be in app folder
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion docker/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
dotnet run -c Release
dotnet Emitter.Server.dll
107 changes: 107 additions & 0 deletions src/Emitter.Runtime/Configuration/ConfigOfCluster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#region Copyright (c) 2009-2016 Misakai Ltd.
/*************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.If not, see<http://www.gnu.org/licenses/>.
*************************************************************************/
#endregion Copyright (c) 2009-2016 Misakai Ltd.

using System;
using System.Linq;
using System.Net;
using Emitter.Providers;
using Emitter.Text.Json;

namespace Emitter.Configuration
{
/// <summary>
/// Represents a configuration of the cluster.
/// </summary>
public class ConfigOfCluster
{
/// <summary>
/// The address to broadcast
/// </summary>
[JsonProperty("broadcast")]
public string BroadcastAddress = "public";

/// <summary>
/// Gets or sets the mesh port.
/// </summary>
[JsonProperty("port")]
public int Port = 4000;

/// <summary>
/// Gets or sets the seed hostname address.
/// </summary>
[JsonProperty("seed")]
public string Seed = "127.0.0.1:4000";

/// <summary>
/// Gets or sets the cluster key.
/// </summary>
[JsonProperty("key")]
public string ClusterKey = "emitter-io";

/// <summary>
/// Resolve the seed endpoints.
/// </summary>
[JsonIgnore]
public IPEndPoint SeedEndpoint
{
get
{
// Parse as URI
Uri uri;
if (!Uri.TryCreate("tcp://" + Seed, UriKind.Absolute, out uri))
return null;

// Resolve DNS
var task = Dns.GetHostAddressesAsync(uri.DnsSafeHost);
task.Wait();

// Get the port
var port = uri.IsDefaultPort ? Port : uri.Port;
var addr = uri.HostNameType == UriHostNameType.Dns
? task.Result.LastOrDefault()
: IPAddress.Parse(uri.Host);

return new IPEndPoint(addr, port);
}
}

/// <summary>
/// Gets the endpoint to broadcast within the mesh.
/// </summary>
[JsonIgnore]
public IPEndPoint BroadcastEndpoint
{
get
{
IPAddress address = null;
var addressString = this.BroadcastAddress.ToLower();
if (addressString == "public")
address = Service.Providers.Resolve<AddressProvider>().GetExternal();
if (addressString == "local")
address = IPAddress.Parse("127.0.0.1");

if (address == null && !IPAddress.TryParse(addressString, out address))
{
Service.Logger.Log(LogLevel.Error, "Unable to parse " + addressString + " as a valid IP Address. Using 127.0.0.1 instead.");
address = IPAddress.Parse("127.0.0.1");
}

return new IPEndPoint(address, Port);
}
}
}
}
54 changes: 54 additions & 0 deletions src/Emitter.Runtime/Configuration/ConfigOfProviders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#region Copyright (c) 2009-2016 Misakai Ltd.
/*************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.If not, see<http://www.gnu.org/licenses/>.
*************************************************************************/
#endregion Copyright (c) 2009-2016 Misakai Ltd.

using System;
using System.Linq;
using Emitter.Providers;
using Emitter.Text.Json;

namespace Emitter.Configuration
{
/// <summary>
/// Represents a configuration for various providers.
/// </summary>
public class ConfigOfProviders
{
/// <summary>
/// Gets or sets the cluster key.
/// </summary>
[JsonProperty("contract")]
public string ContractProviderName = nameof(SingleContractProvider);

/// <summary>
/// Gets or sets the logging.
/// </summary>
[JsonProperty("logging")]
public string LoggingProviderName = nameof(MultiTextLoggingProvider);

/// <summary>
/// Gets or sets the certificate provider.
/// </summary>
[JsonProperty("certificate")]
public string CertificateProviderName = nameof(FileCertificateProvider);

/// <summary>
/// Gets or sets the storage.
/// </summary>
[JsonProperty("storage")]
public string StorageProviderName = null;
}
}
41 changes: 41 additions & 0 deletions src/Emitter.Runtime/Configuration/ConfigOfStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#region Copyright (c) 2009-2016 Misakai Ltd.
/*************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.If not, see<http://www.gnu.org/licenses/>.
*************************************************************************/
#endregion Copyright (c) 2009-2016 Misakai Ltd.

using System;
using System.Linq;
using Emitter.Text.Json;

namespace Emitter.Configuration
{
/// <summary>
/// Represents a configuration for any storage provider.
/// </summary>
public class ConfigOfStorage
{
/// <summary>
/// Gets or sets the storage location.
/// </summary>
[JsonProperty("location")]
public string Location = "";

/// <summary>
/// Gets or sets the connection string for the storage.
/// </summary>
[JsonProperty("connection")]
public string Connection = "";
}
}
50 changes: 50 additions & 0 deletions src/Emitter.Runtime/Configuration/ConfigOfVault.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#region Copyright (c) 2009-2016 Misakai Ltd.
/*************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.If not, see<http://www.gnu.org/licenses/>.
*************************************************************************/
#endregion Copyright (c) 2009-2016 Misakai Ltd.

using System;
using System.Linq;
using Emitter.Text.Json;

namespace Emitter.Configuration
{
/// <summary>
/// Represents a configuration for Hashicorp's Vault.
/// </summary>
public class ConfigOfVault
{
/// <summary>
/// Gets or sets the vault address.
/// </summary>
[JsonProperty("address")]
public string Address = "";

/// <summary>
/// Gets or sets the vault app-id.
/// </summary>
[JsonProperty("app")]
public string Application = "";

/// <summary>
/// Checks whether the vault is configured
/// </summary>
[JsonIgnore]
public bool HasVault
{
get { return !string.IsNullOrWhiteSpace(this.Address) && !string.IsNullOrWhiteSpace(this.Application); }
}
}
}
Loading

0 comments on commit e5e8ca6

Please sign in to comment.