-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugs fixed and upgrade to latest datastax driver for jdk 17 support
- Loading branch information
1 parent
10a5086
commit 972d9e5
Showing
5 changed files
with
53 additions
and
27 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
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
32 changes: 32 additions & 0 deletions
32
server/feed15/src/main/kotlin/info/glennengstrand/newsfeed/daos/NoSqlDao.kt
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 info.glennengstrand.newsfeed.daos | ||
|
||
import com.datastax.oss.driver.api.core.CqlSessionBuilder | ||
import java.net.InetSocketAddress | ||
import java.time.Instant | ||
import java.time.ZoneId | ||
import java.time.format.DateTimeFormatter | ||
import java.util.Locale | ||
import java.util.concurrent.TimeUnit | ||
|
||
open class NoSqlDao { | ||
private val noSqlHost = System.getenv("NOSQL_HOST") ?: "localhost" | ||
private val noSqlKeyspace = System.getenv("NOSQL_KEYSPACE") ?: "activity" | ||
private val cp = InetSocketAddress(noSqlHost, 9042) | ||
private val f = | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||
.withLocale(Locale.US) | ||
.withZone(ZoneId.systemDefault()) | ||
|
||
public val noSqlTtl = System.getenv("NOSQL_TTL")?.toLong() ?: TimeUnit.DAYS.toMillis(1) | ||
|
||
public fun connect(f: (CqlSessionBuilder) -> Unit) { | ||
return f( | ||
CqlSessionBuilder() | ||
.addContactPoint(cp) | ||
.withLocalDatacenter("datacenter1") | ||
.withKeyspace(noSqlKeyspace), | ||
) | ||
} | ||
|
||
public fun format(v: Instant?): String = v?.let { f.format(it) } ?: f.format(Instant.now()) | ||
} |
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