Set up loading of plugins.
This commit is contained in:
parent
8cde69a483
commit
5b2557b3f4
|
@ -59,20 +59,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IProjectPlugin
|
|
||||||
{
|
|
||||||
void Announce();
|
|
||||||
void Decommission();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IHasLogPrefix
|
|
||||||
{
|
|
||||||
string LogPrefix { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IHasMetadata
|
|
||||||
{
|
|
||||||
void AddMetadata(IAddMetadata metadata);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
using Utils;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
public interface IProjectPlugin
|
||||||
|
{
|
||||||
|
void Announce();
|
||||||
|
void Decommission();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IHasLogPrefix
|
||||||
|
{
|
||||||
|
string LogPrefix { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IHasMetadata
|
||||||
|
{
|
||||||
|
void AddMetadata(IAddMetadata metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ProjectPlugin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// On some platforms and in some cases, not all required plugin assemblies are automatically loaded into the app domain.
|
||||||
|
/// In this case, the runtime needs a slight push to load it before the EntryPoint class is instantiated.
|
||||||
|
/// Used ProjectPlugin.Load<>() before you create an EntryPoint to ensure all plugins you want to use are loaded.
|
||||||
|
/// </summary>
|
||||||
|
public static void Load<T>() where T : IProjectPlugin
|
||||||
|
{
|
||||||
|
var type = typeof(T);
|
||||||
|
FrameworkAssert.That(type != null, $"Unable to load plugin.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,14 @@ namespace ContinuousTests
|
||||||
{
|
{
|
||||||
public class EntryPointFactory
|
public class EntryPointFactory
|
||||||
{
|
{
|
||||||
|
public EntryPointFactory()
|
||||||
|
{
|
||||||
|
ProjectPlugin.Load<CodexPlugin.CodexPlugin>();
|
||||||
|
ProjectPlugin.Load<CodexContractsPlugin.CodexContractsPlugin>();
|
||||||
|
ProjectPlugin.Load<GethPlugin.GethPlugin>();
|
||||||
|
ProjectPlugin.Load<MetricsPlugin.MetricsPlugin>();
|
||||||
|
}
|
||||||
|
|
||||||
public EntryPoint CreateEntryPoint(string kubeConfigFile, string dataFilePath, string customNamespace, ILog log)
|
public EntryPoint CreateEntryPoint(string kubeConfigFile, string dataFilePath, string customNamespace, ILog log)
|
||||||
{
|
{
|
||||||
var kubeConfig = GetKubeConfig(kubeConfigFile);
|
var kubeConfig = GetKubeConfig(kubeConfigFile);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
using CodexContractsPlugin;
|
using CodexContractsPlugin;
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
|
using Core;
|
||||||
using DistTestCore;
|
using DistTestCore;
|
||||||
using DistTestCore.Helpers;
|
using DistTestCore.Helpers;
|
||||||
using GethPlugin;
|
using GethPlugin;
|
||||||
using NUnit.Framework.Constraints;
|
using NUnit.Framework.Constraints;
|
||||||
using Utils;
|
|
||||||
|
|
||||||
namespace Tests
|
namespace Tests
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,14 @@ namespace Tests
|
||||||
{
|
{
|
||||||
private readonly List<ICodexNode> onlineCodexNodes = new List<ICodexNode>();
|
private readonly List<ICodexNode> onlineCodexNodes = new List<ICodexNode>();
|
||||||
|
|
||||||
|
public CodexDistTest()
|
||||||
|
{
|
||||||
|
ProjectPlugin.Load<CodexPlugin.CodexPlugin>();
|
||||||
|
ProjectPlugin.Load<CodexContractsPlugin.CodexContractsPlugin>();
|
||||||
|
ProjectPlugin.Load<GethPlugin.GethPlugin>();
|
||||||
|
ProjectPlugin.Load<MetricsPlugin.MetricsPlugin>();
|
||||||
|
}
|
||||||
|
|
||||||
public ICodexNode AddCodex()
|
public ICodexNode AddCodex()
|
||||||
{
|
{
|
||||||
return AddCodex(s => { });
|
return AddCodex(s => { });
|
||||||
|
|
|
@ -19,6 +19,10 @@ namespace CodexNetDeployer
|
||||||
this.config = config;
|
this.config = config;
|
||||||
peerConnectivityChecker = new PeerConnectivityChecker();
|
peerConnectivityChecker = new PeerConnectivityChecker();
|
||||||
|
|
||||||
|
ProjectPlugin.Load<CodexPlugin.CodexPlugin>();
|
||||||
|
ProjectPlugin.Load<CodexContractsPlugin.CodexContractsPlugin>();
|
||||||
|
ProjectPlugin.Load<GethPlugin.GethPlugin>();
|
||||||
|
ProjectPlugin.Load<MetricsPlugin.MetricsPlugin>();
|
||||||
entryPoint = CreateEntryPoint(new NullLog());
|
entryPoint = CreateEntryPoint(new NullLog());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +31,6 @@ namespace CodexNetDeployer
|
||||||
var ep = CreateEntryPoint(new ConsoleLog());
|
var ep = CreateEntryPoint(new ConsoleLog());
|
||||||
|
|
||||||
Log("Using plugins:" + Environment.NewLine);
|
Log("Using plugins:" + Environment.NewLine);
|
||||||
ep.Announce();
|
|
||||||
Log("");
|
|
||||||
var metadata = ep.GetPluginMetadata();
|
var metadata = ep.GetPluginMetadata();
|
||||||
foreach (var entry in metadata)
|
foreach (var entry in metadata)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue