-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dynamodb wiring with dagger
- Loading branch information
1 parent
bc15ac2
commit 70e467b
Showing
7 changed files
with
111 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
immersion_tracker_api/src/main/java/com/jordansimsmith/immersiontracker/DynamoDbModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.jordansimsmith.immersiontracker; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
import java.net.URI; | ||
import javax.annotation.Nullable; | ||
import javax.inject.Named; | ||
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; | ||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient; | ||
|
||
@Module | ||
public class DynamoDbModule { | ||
|
||
@Provides | ||
public DynamoDbClient dynamoDbClient(@Nullable @Named("dynamoDbEndpoint") URI dynamoDbEndpoint) { | ||
var builder = DynamoDbClient.builder(); | ||
if (dynamoDbEndpoint != null) { | ||
builder.endpointOverride(dynamoDbEndpoint); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
|
||
@Provides | ||
public DynamoDbEnhancedClient dynamoDbEnhancedClient(DynamoDbClient dynamoDbClient) { | ||
return DynamoDbEnhancedClient.builder().dynamoDbClient(dynamoDbClient).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
immersion_tracker_api/src/main/java/com/jordansimsmith/immersiontracker/Hello.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...cker_api/src/main/java/com/jordansimsmith/immersiontracker/ImmersionTrackerComponent.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...racker_api/src/main/java/com/jordansimsmith/immersiontracker/ImmersionTrackerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.jordansimsmith.immersiontracker; | ||
|
||
import dagger.BindsInstance; | ||
import dagger.Component; | ||
import java.net.URI; | ||
import javax.inject.Named; | ||
import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; | ||
import software.amazon.awssdk.services.dynamodb.DynamoDbClient; | ||
|
||
@Component(modules = {DynamoDbModule.class}) | ||
public interface ImmersionTrackerFactory { | ||
|
||
DynamoDbClient dynamoDbClient(); | ||
|
||
DynamoDbEnhancedClient dynamoDbEnhancedClient(); | ||
|
||
@Component.Builder | ||
interface Builder { | ||
@BindsInstance | ||
Builder dynamoDbEndpoint(@Named("dynamoDbEndpoint") URI dynamoDbEndpoint); | ||
|
||
ImmersionTrackerFactory build(); | ||
} | ||
|
||
static ImmersionTrackerFactory create() { | ||
return DaggerImmersionTrackerFactory.builder().build(); | ||
} | ||
|
||
static ImmersionTrackerFactory.Builder builder() { | ||
return DaggerImmersionTrackerFactory.builder(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters