11using FaasNet . Common ;
22using FaasNet . EventMesh . Protocols ;
33using FaasNet . EventMesh . Service ;
4+ using FaasNet . EventMesh . Sink ;
45
56using IHost host = Host . CreateDefaultBuilder ( args )
67 . UseWindowsService ( o =>
1314 } )
1415 . ConfigureServices ( ( hostContext , services ) =>
1516 {
16- var pluginsDirectory = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "plugins" ) ;
17- IEnumerable < string > pluginPaths = new string [ 0 ] ;
18- if ( Directory . Exists ( pluginsDirectory ) ) pluginPaths = Directory . EnumerateDirectories ( pluginsDirectory ) ;
19- var discoveredProtocolPlugins = pluginPaths . Select ( p =>
20- {
21- if ( ProtocolPluginEntryDiscovery . TryExtract ( p , out IDiscoveredPlugin discoveredPlugin ) ) return discoveredPlugin ;
22- return null ;
23- } ) . Where ( p => p != null ) ;
2417 var options = hostContext . Configuration . Get < EventMeshServerOptions > ( ) ;
2518 var serverBuilder = services . AddEventMeshServer ( consensusNodeCallback : o => o . Port = options . Port )
26- . UseRocksDB ( o =>
27- {
28- o . SubPath = $ "node{ options . Port } ";
29- } ) ;
30- foreach ( var discoveredPlugin in discoveredProtocolPlugins ) discoveredPlugin . Load ( serverBuilder . Services ) ;
31- services . AddHostedService < EventMeshServerWorker > ( ) ;
19+ . UseRocksDB ( o =>
20+ {
21+ o . SubPath = $ "node{ options . Port } ";
22+ } )
23+ . UseSinkRocksDB ( ) ;
24+ LoadProtocolPlugins ( serverBuilder . Services ) ;
25+ LoadSinkPlugins ( serverBuilder . Services ) ;
3226 } ) . Build ( ) ;
33- await host . RunAsync ( ) ;
27+ await host . RunAsync ( ) ;
28+
29+ static void LoadProtocolPlugins ( IServiceCollection services )
30+ {
31+ var pluginsDirectory = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "protocolPlugins" ) ;
32+ IEnumerable < string > pluginPaths = new string [ 0 ] ;
33+ if ( Directory . Exists ( pluginsDirectory ) ) pluginPaths = Directory . EnumerateDirectories ( pluginsDirectory ) ;
34+ var discoveredProtocolPlugins = pluginPaths . Select ( p =>
35+ {
36+ if ( ProtocolPluginEntryDiscovery . TryExtract ( p , out FaasNet . EventMesh . Protocols . IDiscoveredPlugin discoveredPlugin ) ) return discoveredPlugin ;
37+ return null ;
38+ } ) . Where ( p => p != null ) ;
39+ foreach ( var discoveredPlugin in discoveredProtocolPlugins ) discoveredPlugin . Load ( services ) ;
40+ services . AddHostedService < EventMeshServerWorker > ( ) ;
41+ }
42+
43+ static void LoadSinkPlugins ( IServiceCollection services )
44+ {
45+ var pluginsDirectory = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "sinkPlugins" ) ;
46+ IEnumerable < string > pluginPaths = new string [ 0 ] ;
47+ if ( Directory . Exists ( pluginsDirectory ) ) pluginPaths = Directory . EnumerateDirectories ( pluginsDirectory ) ;
48+ var discoveredSinkPlugins = pluginPaths . Select ( p =>
49+ {
50+ if ( SinkPluginEntryDiscovery . TryExtract ( p , out FaasNet . EventMesh . Sink . IDiscoveredPlugin discoveredPlugin ) ) return discoveredPlugin ;
51+ return null ;
52+ } ) . Where ( p => p != null ) ;
53+ foreach ( var discoveredPlugin in discoveredSinkPlugins ) discoveredPlugin . Load ( services ) ;
54+ services . AddHostedService < EventMeshServerSinkWorker > ( ) ;
55+ }
0 commit comments