/// <summary> /// Initializes a new instance of the <see cref="VehicleInventoryDbEventProcessor" /> class. /// </summary> /// <param name="client">The client.</param> /// <param name="dynamoDbContext">The dynamo database context.</param> public VehicleInventoryDbEventProcessor(IElasticClient client, IDynamoDBContext dynamoDbContext) { var config = new DynamoDBContextConfig { ConsistentRead = true, TableNamePrefix = $"dev_" }; // this is used for more integratin level testing. if (client == null) { var creds = new StaticCredentialsProvider( new AwsCredentials { AccessKey = string.Empty, SecretKey = string.Empty, }); var node = new SingleNodeConnectionPool( new Uri(string.Empty)); this.awsHttpConnection = new AwsHttpConnection(RegionEndpoint.USEast1.SystemName, creds); // setup index settings for each strongly typed object var settings = new ConnectionSettings(node, this.awsHttpConnection) .DisableDirectStreaming() .InferMappingFor <InventoryItem>(m => m.IdProperty(p => p.VIN)) .MapDefaultTypeIndices(m => m.Add(typeof(InventoryItem), "dev_vehicle_inventory")); this.elasticClient = new ElasticClient(settings); IAmazonDynamoDB dynamoDbClient = new AmazonDynamoDBClient(RegionEndpoint.USEast1); this.indexer = new ElasticSearchIndexer <InventoryItem>(dynamoDbClient, Environment.GetEnvironmentVariable("environment"), this.elasticClient); this.dynamoDbContext = new DynamoDBContext(dynamoDbClient, config); } else { this.elasticClient = client; this.dynamoDbContext = dynamoDbContext; } }
/// <summary> /// Initializes a new instance of the <see cref="VehicleInventoryDbEventProcessor"/> class. /// </summary> public VehicleInventoryDbEventProcessor() { this.awsHttpConnection = new AwsHttpConnection(RegionEndpoint.USEast1.SystemName); var node = new SingleNodeConnectionPool(new Uri(Environment.GetEnvironmentVariable("elasticSearchURL"))); // setup index settings for each strongly typed object var settings = new ConnectionSettings(node, this.awsHttpConnection) .DisableDirectStreaming() .InferMappingFor <InventoryItem>(m => m.IdProperty(p => p.VIN)) .MapDefaultTypeIndices(m => m.Add(typeof(InventoryItem), "dev_vehicle_inventory")); this.elasticClient = new ElasticClient(settings); IAmazonDynamoDB dynamoDbClient = new AmazonDynamoDBClient(); this.indexer = new ElasticSearchIndexer <InventoryItem>(dynamoDbClient, Environment.GetEnvironmentVariable("environment"), this.elasticClient); var config = new DynamoDBContextConfig { ConsistentRead = true, TableNamePrefix = $"dev_" }; this.dynamoDbContext = new DynamoDBContext(dynamoDbClient, config); }