1
- using System ;
2
- using System . Reflection ;
1
+ using System . Reflection ;
3
2
using System . Threading . Tasks ;
4
3
using Amazon ;
5
4
using Amazon . DynamoDBv2 ;
6
5
using Amazon . Kinesis ;
7
6
using Microsoft . Extensions . Configuration ;
8
7
using Serilog ;
9
- using Serilog . Events ;
10
- using Serilog . Formatting . Json ;
11
- using SeriLog . LogSanitizingFormatter ;
12
8
using WorkerService . EventProcessors ;
13
- using WorkerService . KinesisNet ;
14
- using WorkerService . KinesisNet . Interface ;
15
- using WorkerService . KinesisNet . Model ;
16
- using WorkerService . KinesisNet . Persistance ;
9
+ using KinesisNet ;
17
10
using static System . Threading . Thread ;
18
11
using static System . Threading . Timeout ;
19
- using static System . Console ;
20
12
21
13
namespace WorkerService
22
14
{
23
15
public class Program
24
16
{
25
- private static Environment _environment ;
26
- private static KManager _kManager ;
17
+ private static Environment environment ;
18
+ private static KManager kManager ;
27
19
28
20
public static void Main ( string [ ] args )
29
21
{
@@ -34,8 +26,7 @@ public static void Main(string[] args)
34
26
35
27
Log . Debug ( "Testing debug logging" ) ;
36
28
37
- //new LoggerConfiguration().WriteTo.Co
38
- _environment = new Environment
29
+ environment = new Environment
39
30
(
40
31
System . Environment . GetEnvironmentVariable ( "REGION" ) ,
41
32
System . Environment . GetEnvironmentVariable ( "DC" ) ,
@@ -47,7 +38,7 @@ public static void Main(string[] args)
47
38
. InformationalVersion
48
39
) ;
49
40
50
- Log . Information ( "{@Environment}" , _environment ) ;
41
+ Log . Information ( "{@Environment}" , environment ) ;
51
42
52
43
Log . Information ( "Starting configuration" ) ;
53
44
@@ -67,29 +58,29 @@ public static void Main(string[] args)
67
58
68
59
private static void StopListeningToEvents ( )
69
60
{
70
- _kManager . Consumer . Stop ( ) ;
61
+ kManager . Consumer . Stop ( ) ;
71
62
}
72
63
73
64
public static void StartListeningForEvents ( )
74
65
{
75
66
Log . Debug ( "Entering StartListeningForEvents" ) ;
76
67
var kinesisStreamName = "RoleStream.LIVE" ;
77
- var kinesisWorkerId = Assembly . GetEntryAssembly ( ) . GetName ( ) . Name + "-" + _environment . Env ;
68
+ var kinesisWorkerId = Assembly . GetEntryAssembly ( ) . GetName ( ) . Name + "-" + environment . Env ;
78
69
79
70
Log . Information ( "KManager variables:" ) ;
80
71
Log . Information ( $ " StreamName: { kinesisStreamName } ") ;
81
72
Log . Information ( $ " WorkerId: { kinesisWorkerId } ") ;
82
73
83
74
Log . Debug ( "Creating Dyanmo client" ) ;
84
- var dynamoClient = new AmazonDynamoDBClient ( new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint . GetBySystemName ( _environment . AwsRegion ) } ) ;
75
+ var dynamoClient = new AmazonDynamoDBClient ( new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint . GetBySystemName ( environment . AwsRegion ) } ) ;
85
76
Log . Debug ( "Creating Kinesis client" ) ;
86
- var kinesisClient = new AmazonKinesisClient ( new AmazonKinesisConfig { RegionEndpoint = RegionEndpoint . GetBySystemName ( _environment . AwsRegion ) } ) ;
77
+ var kinesisClient = new AmazonKinesisClient ( new AmazonKinesisConfig { RegionEndpoint = RegionEndpoint . GetBySystemName ( environment . AwsRegion ) } ) ;
87
78
88
79
Log . Debug ( "Starting Kmanager" ) ;
89
- _kManager = new KManager ( dynamoClient , kinesisClient , kinesisStreamName , kinesisWorkerId ) ;
80
+ kManager = new KManager ( dynamoClient , kinesisClient , kinesisStreamName , kinesisWorkerId ) ;
90
81
91
82
Log . Debug ( "Starting consumer" ) ;
92
- Task . Run ( ( ) => _kManager . Consumer . Start ( new RolesEventProcessor ( ) ) ) ;
83
+ Task . Run ( ( ) => kManager . Consumer . Start ( new RolesEventProcessor ( ) ) ) ;
93
84
}
94
85
}
95
86
}
0 commit comments