-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add bin-stash to CA
- Loading branch information
Showing
9 changed files
with
256 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
src/main/java/co/com/bancolombia/factory/adapters/DrivenAdapterBinStash.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,40 @@ | ||
package co.com.bancolombia.factory.adapters; | ||
|
||
import static co.com.bancolombia.utils.Utils.buildImplementationFromProject; | ||
|
||
import co.com.bancolombia.exceptions.CleanException; | ||
import co.com.bancolombia.factory.ModuleBuilder; | ||
import co.com.bancolombia.factory.ModuleFactory; | ||
import co.com.bancolombia.factory.commons.ObjectMapperFactory; | ||
import java.io.IOException; | ||
|
||
public class DrivenAdapterBinStash implements ModuleFactory { | ||
|
||
@Override | ||
public void buildModule(ModuleBuilder builder) throws IOException, CleanException { | ||
|
||
CacheMode cacheMode = (CacheMode) builder.getParam("task-param-cache-mode"); | ||
builder.setupFromTemplate("driven-adapter/bin-stash"); | ||
|
||
builder.addParam("include-local", cacheMode.equals(CacheMode.LOCAL)); | ||
builder.addParam("include-hybrid", cacheMode.equals(CacheMode.HYBRID)); | ||
builder.addParam("include-centralized", cacheMode.equals(CacheMode.CENTRALIZED)); | ||
builder.appendToSettings("bin-stash", "infrastructure/driven-adapters"); | ||
String dependency = buildImplementationFromProject(builder.isKotlin(), ":bin-stash"); | ||
builder.appendDependencyToModule("app-service", dependency); | ||
|
||
builder.appendToProperties("stash.memory").put("maxSize", "10000"); | ||
builder.appendToProperties("stash.redis").put("host", "myredis.host"); | ||
builder.appendToProperties("stash.redis").put("port", "6379"); | ||
builder.appendToProperties("stash.redis").put("database", "0"); | ||
builder.appendToProperties("stash.redis").put("password", "mypwd"); | ||
|
||
new ObjectMapperFactory().buildModule(builder); | ||
} | ||
|
||
public enum CacheMode { | ||
LOCAL, | ||
HYBRID, | ||
CENTRALIZED | ||
} | ||
} |
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
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
53 changes: 53 additions & 0 deletions
53
src/main/resources/driven-adapter/bin-stash/bin-stash-local-cache-config.java.mustache
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,53 @@ | ||
package {{package}}.binstash.config; | ||
|
||
import co.com.bancolombia.binstash.model.api.ObjectCache; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
{{#include-local}} | ||
import co.com.bancolombia.binstash.LocalCacheFactory; | ||
{{/include-local}} | ||
|
||
{{#include-centralized}} | ||
import co.com.bancolombia.binstash.CentralizedCacheFactory; | ||
{{/include-centralized}} | ||
|
||
{{#include-hibrid}} | ||
import co.com.bancolombia.binstash.HybridCacheFactory; | ||
import co.com.bancolombia.binstash.model.SyncRule; | ||
import java.util.Collections; | ||
import java.util.List; | ||
{{/include-hibrid}} | ||
|
||
@Configuration | ||
public class BinStashConfiguration { | ||
{{#include-local}} | ||
@Bean | ||
public ObjectCache<Object/*Replace for domain model*/> objectCache(LocalCacheFactory<Object> localCacheFactory) { | ||
return localCacheFactory.newObjectCache(); | ||
} | ||
{{/include-local}} | ||
|
||
{{#include-centralized }} | ||
@Bean | ||
public ObjectCache<Object/*Replace for domain model*/> objectCache(CentralizedCacheFactory<Object> centralizedCacheFactory) { | ||
return centralizedCacheFactory.newObjectCache(); | ||
} | ||
{{/include-centralized }} | ||
|
||
{{#include-hybrid}} | ||
@Bean | ||
public List<SyncRule> cacheSyncRules() { | ||
SyncRule simpleSyncRule = (keyArg, syncType) -> true; | ||
return Collections.singletonList(simpleSyncRule); | ||
} | ||
|
||
@Bean | ||
public ObjectCache<Object/*Replace for domain model*/> objectCache(HybridCacheFactory<Object/*Replace for domain model*/> cacheFactory, | ||
List<SyncRule> cacheSyncRules) { | ||
return cacheFactory.newObjectCache(cacheSyncRules); | ||
} | ||
{{/include-hybrid}} | ||
|
||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/resources/driven-adapter/bin-stash/bin-stash-local-cache-config.kt.mustache
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,52 @@ | ||
package {{package}}.binstash.config | ||
|
||
import co.com.bancolombia.binstash.model.api.ObjectCache | ||
import org.springframework.context.annotation.Bean | ||
{{#include-local}} | ||
import co.com.bancolombia.binstash.LocalCacheFactory | ||
{{/include-local}} | ||
{{#include-centralized}} | ||
import co.com.bancolombia.binstash.CentralizedCacheFactory | ||
{{/include-centralized}} | ||
{{#include-hibrid}} | ||
import co.com.bancolombia.binstash.HybridCacheFactory | ||
import co.com.bancolombia.binstash.model.SyncRule | ||
import java.util.Collections | ||
import java.util.List | ||
{{/include-hibrid}} | ||
|
||
@Configuration | ||
open class BinStashConfiguration { | ||
{{#include-local}} | ||
@Bean | ||
open fun objectCache(localCacheFactory: LocalCacheFactory<Any?>): ObjectCache<Any?>? { | ||
return localCacheFactory.newObjectCache() | ||
} | ||
{{/include-local}} | ||
|
||
{{#include-centralized }} | ||
@Bean | ||
open fun objectCache(centralizedCacheFactory: CentralizedCacheFactory<Any?>): ObjectCache<Any?>? { | ||
return centralizedCacheFactory.newObjectCache() | ||
} | ||
{{/include-centralized }} | ||
|
||
{{#include-hybrid}} | ||
@Bean | ||
open fun cacheSyncRules(): List<SyncRule?>? { | ||
val simpleSyncRule = SyncRule { keyArg, syncType -> true } | ||
return Collections.singletonList(simpleSyncRule) | ||
} | ||
|
||
@Bean | ||
fun objectCache( | ||
cacheFactory: HybridCacheFactory<Any?>, | ||
cacheSyncRules: List<SyncRule?>? | ||
): ObjectCache<Any?>? { | ||
return cacheFactory.newObjectCache(cacheSyncRules) | ||
} | ||
{{/include-hybrid}} | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/resources/driven-adapter/bin-stash/build.gradle.kts.mustache
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,14 @@ | ||
dependencies { | ||
implementation project(':model') | ||
{{#include-local}} | ||
implementation 'com.github.bancolombia:bin-stash-local:1.0.3' | ||
{{/include-local}} | ||
|
||
{{#include-centralized }} | ||
implementation 'com.github.bancolombia:bin-stash-centralized:1.0.3' | ||
{{/include-centralized }} | ||
|
||
{{#include-hybrid}} | ||
implementation 'com.github.bancolombia:bin-stash-hybrid:1.0.3' | ||
{{/include-hybrid}} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/driven-adapter/bin-stash/build.gradle.mustache
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,12 @@ | ||
dependencies { | ||
implementation project(':model') | ||
{{#include-local}} | ||
implementation 'com.github.bancolombia:bin-stash-local:1.0.3' | ||
{{/include-local}} | ||
{{#include-centralized }} | ||
implementation 'com.github.bancolombia:bin-stash-centralized:1.0.3' | ||
{{/include-centralized }} | ||
{{#include-hybrid}} | ||
implementation 'com.github.bancolombia:bin-stash-hybrid:1.0.3' | ||
{{/include-hybrid}} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/driven-adapter/bin-stash/definition.json
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,12 @@ | ||
{ | ||
"folders": [], | ||
"files": {}, | ||
"java": { | ||
"driven-adapter/bin-stash/bin-stash-local-cache-config.java.mustache": "infrastructure/driven-adapters/bin-stash/src/main/{{language}}/{{packagePath}}/binstash/config/BinStashCacheConfig.java", | ||
"driven-adapter/bin-stash/build.gradle.mustache": "infrastructure/driven-adapters/bin-stash/build.gradle" | ||
}, | ||
"kotlin": { | ||
"driven-adapter/bin-stash/bin-stash-local-cache-config.kt.mustache": "infrastructure/driven-adapters/bin-stash/src/main/{{language}}/{{packagePath}}/binstash/config/BinStashCacheConfig.kt", | ||
"driven-adapter/bin-stash/build.gradle.kts.mustache": "infrastructure/driven-adapters/bin-stash/build.gradle.kts" | ||
} | ||
} |