Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DatabaseModule.cs
1using System;
2using System.IO;
3using System.Threading;
4using System.Threading.Tasks;
6
8{
12 [Singleton]
13 public class DatabaseModule : IModule
14 {
15 private static IDatabaseProvider databaseProvider = null;
16 private static ILedgerProvider ledgerProvider = null;
17
22 {
23 }
24
28 public async Task Start()
29 {
31 await Database.Provider.Start();
32
34 await Ledger.Provider.Start();
35
36 databaseProvider = null;
37 ledgerProvider = null;
38 }
39
43 public async Task Stop()
44 {
46 {
47 databaseProvider = Database.Stop();
48 await databaseProvider.Stop();
49 }
50
52 {
53 ledgerProvider = Ledger.Stop();
54 await ledgerProvider.Stop();
55 }
56 }
57
61 public static async Task Flush()
62 {
64 await Database.Provider.Flush();
65
67 await Ledger.Provider.Flush();
68
69 if (!(databaseProvider is null))
70 await databaseProvider.Flush();
71
72 if (!(ledgerProvider is null))
73 await ledgerProvider.Flush();
74 }
75
76 }
77}
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
static bool HasProvider
If a database provider is registered.
Definition: Database.cs:79
static IDatabaseProvider Provider
Registered database provider.
Definition: Database.cs:57
Static interface for ledger persistence. In order to work, a ledger provider has to be assigned to it...
Definition: Ledger.cs:14
static bool HasProvider
If a ledger provider is registered.
Definition: Ledger.cs:105
static ILedgerProvider Provider
Registered ledger provider.
Definition: Ledger.cs:83
async Task Start()
Starts the module.
async Task Stop()
Stops the module.
static async Task Flush()
Flushes any remaining data to disk.
Interface for database providers that can be plugged into the static Database class.
Task Flush()
Persists any pending changes.
Task Start()
Called when processing starts.
Task Stop()
Called when processing ends.
Interface for ledger providers that can be plugged into the static Ledger class.
Task Flush()
Persists any pending changes.
Task Stop()
Called when processing ends.
Task Start()
Called when processing starts.
Interface for late-bound modules loaded at runtime.
Definition: IModule.cs:9