Skip to content

Commit

Permalink
Merge pull request #462 from laserdisc-io/defaults
Browse files Browse the repository at this point in the history
move to sbt defaults
  • Loading branch information
barryoneill authored Nov 26, 2024
2 parents 8372cc8 + 12b3bcc commit 9b12932
Show file tree
Hide file tree
Showing 36 changed files with 186 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
~/.sbt
key: sbt-${{ hashFiles('**/build.sbt') }}
- name: Run tests
run: sbt +clean +test +doc
run: sbt build

2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v14
with:
java-version: [email protected]
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
Expand Down
39 changes: 38 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# ------------------ autogenerated file - do not edit -------------------
# This file was generated by sbt-laserdisc-defaults
#
# Please check in any changes generated in this file (for IDE support)
#
# To make changes, please publish a new version of the plugin at:
# https://github.com/laserdisc-io/sbt-laserdisc-defaults
#
# To temporarily disable generation, set this at the top of build.sbt:
# ThisBuild / laserdiscGitIgnoreGenOn := false
# -----------------------------------------------------------------------

# tip: use a "global" gitignore (core.excludesfile) for your own, local, personal preferences
# See: https://gist.github.com/subfuzion/db7f57fff2fb6998a16c

# scala / sbt / java
project/project/
project/target/
target/
.sbtopts
.tasty

# intellij
.idea/
*.iml

# metals / bsp
.metals/
.bloop/
.bsp/
.DS_Store
project/metals.sbt

# vscode
.vscode/

# terraform
.terraform/
*.tfplan
*.terraform.lock.hcl

# mac
.DS_Store
17 changes: 15 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# ------------------ autogenerated file - do not edit -------------------
# This file was generated by sbt-laserdisc-defaults
#
# Please check in any changes generated in this file (for IDE support)
#
# To make changes, please publish a new version of the plugin at:
# https://github.com/laserdisc-io/sbt-laserdisc-defaults
#
# To temporarily disable generation, set this at the top of build.sbt:
# ThisBuild / laserdiscScalaFmtGenOn := false
# -----------------------------------------------------------------------

version=3.8.3

maxColumn = 140
style = default
align.preset = more

runner.dialect = scala213source3
project.layout = StandardConvention
runner.dialect = scala3
fileOverride {
"glob:**/scala-3/**" { runner.dialect = scala3 }
"lang:scala-2" = scala213source3
}

danglingParentheses.preset = true
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Dmytro Semenov & Barry O'Neill

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.laserdisc.mysql.binlog.models

import cats.implicits.*
import doobie.*
import doobie.implicits.*
import cats.implicits._
import doobie._
import doobie.implicits._
import cats.effect.MonadCancel

case class BinaryLogs(fileName: String, size: Long)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.DeleteRowsEventData as JDeleteRowsEventData
import com.github.shyiko.mysql.binlog.event.{DeleteRowsEventData => JDeleteRowsEventData}

import scala.jdk.CollectionConverters.*
import scala.jdk.CollectionConverters._
object DeleteRowsEventData {
def unapply(arg: JDeleteRowsEventData): Option[(Long, List[Array[Serializable]], Array[Int])] =
Some((arg.getTableId, arg.getRows.asScala.toList, arg.getIncludedColumns.stream().toArray))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.{EventHeaderV4 as JEventHeaderV4, EventType}
import com.github.shyiko.mysql.binlog.event.{EventHeaderV4 => JEventHeaderV4, EventType}

object EventHeaderV4 {
def unapply(arg: JEventHeaderV4): Option[(EventType, Long, Long)] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.QueryEventData as JQueryEventData
import com.github.shyiko.mysql.binlog.event.{QueryEventData => JQueryEventData}

object QueryEventData {
def truncateTable(sql: String) = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.RotateEventData as JRotateEventData
import com.github.shyiko.mysql.binlog.event.{RotateEventData => JRotateEventData}

object RotateEventData {
def unapply(arg: JRotateEventData): Option[(String, Long)] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.laserdisc.mysql.binlog.models

import doobie.*
import doobie.implicits.*
import doobie._
import doobie.implicits._

import scala.collection.mutable
import cats.effect.MonadCancel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.TableMapEventData as JTableMapEventData
import com.github.shyiko.mysql.binlog.event.{TableMapEventData => JTableMapEventData}

object TableMapEventData {
def unapply(arg: JTableMapEventData): Option[(Long, String, String)] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.UpdateRowsEventData as JUpdateRowsEventData
import com.github.shyiko.mysql.binlog.event.{UpdateRowsEventData => JUpdateRowsEventData}

import scala.jdk.CollectionConverters.*
import scala.jdk.CollectionConverters._

object UpdateRowsEventData {
def unapply(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.WriteRowsEventData as JWriteRowsEventData
import com.github.shyiko.mysql.binlog.event.{WriteRowsEventData => JWriteRowsEventData}

import scala.jdk.CollectionConverters.*
import scala.jdk.CollectionConverters._

object WriteRowsEventData {
def unapply(arg: JWriteRowsEventData): Option[(Long, List[Array[Serializable]], Array[Int])] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.laserdisc.mysql.binlog.models

import com.github.shyiko.mysql.binlog.event.XidEventData as JXidEventData
import com.github.shyiko.mysql.binlog.event.{XidEventData => JXidEventData}

object XidEventData {
def unapply(arg: JXidEventData): Option[Long] = Some(arg.getXid)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.laserdisc.mysql.binlog

import cats.effect.Sync
import cats.implicits.*
import cats.implicits._
import com.github.shyiko.mysql.binlog.BinaryLogClient
import io.laserdisc.mysql.binlog.checkpoint.BinlogOffset
import io.laserdisc.mysql.binlog.config.{BinLogConfig, BinLogConfigOps}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.laserdisc.mysql.binlog

import cats.data.Kleisli
import cats.implicits.*
import cats.implicits._
import io.circe.Json
import io.laserdisc.mysql.binlog.event.EventMessage
import io.laserdisc.mysql.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.laserdisc.mysql.binlog

import cats.effect.*
import doobie.*
import cats.effect._
import doobie._
import doobie.hikari.HikariTransactor
import io.laserdisc.mysql.binlog.config.BinLogConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.laserdisc.mysql.binlog.stream

import cats.effect.std.{Dispatcher, Queue}
import cats.effect.{Async, IO, LiftIO}
import cats.implicits.*
import cats.implicits._
import com.github.shyiko.mysql.binlog.BinaryLogClient
import com.github.shyiko.mysql.binlog.event.Event
import fs2.Stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package io.laserdisc.mysql.binlog.stream

import cats.data.State
import cats.effect.{Ref, Sync}
import cats.implicits.*
import cats.implicits._
import com.github.shyiko.mysql.binlog.BinaryLogClient
import com.github.shyiko.mysql.binlog.event.EventType.{EXT_UPDATE_ROWS, UPDATE_ROWS}
import com.github.shyiko.mysql.binlog.event.deserialization.json.JsonBinary
import com.github.shyiko.mysql.binlog.event.{Event, EventData, EventHeaderV4 as JEventHeaderV4, EventType}
import com.github.shyiko.mysql.binlog.event.{Event, EventData, EventHeaderV4 => JEventHeaderV4, EventType}
import io.circe.Json
import io.laserdisc.mysql.binlog.event.EventMessage
import io.laserdisc.mysql.binlog.models.*
import io.laserdisc.mysql.binlog.models._
import org.typelevel.log4cats.Logger

import java.math.BigDecimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.laserdisc.mysql.binlog

import cats.effect.kernel.Ref
import cats.effect.{Concurrent, Sync}
import cats.implicits.*
import cats.implicits._
import com.github.shyiko.mysql.binlog.event.Event
import org.typelevel.log4cats.Logger
import io.laserdisc.mysql.binlog.event.EventMessage
Expand All @@ -13,14 +13,14 @@ package object stream {
schema: String
): fs2.Pipe[F, Event, EventMessage] =
_.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg =>
fs2.Stream.eval(warnBigTransactionPackage(pkg)) >> fs2.Stream(pkg.events*)
fs2.Stream.eval(warnBigTransactionPackage(pkg)) >> fs2.Stream(pkg.events: _*)
)

def streamCompactedEvents[F[_]: Concurrent: Logger](
transactionState: Ref[F, TransactionState],
schema: String
): fs2.Pipe[F, Event, EventMessage] =
_.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg => fs2.Stream(compaction.compact(pkg.events)*))
_.through(streamTransactionPackages[F](transactionState, schema)).flatMap(pkg => fs2.Stream(compaction.compact(pkg.events): _*))

def streamTransactionPackages[F[_]: Concurrent: Logger](
transactionState: Ref[F, TransactionState],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cats.effect.unsafe.implicits.global
import com.dimafeng.testcontainers.ForAllTestContainer
import com.github.shyiko.mysql.binlog.BinaryLogClient
import db.MySqlContainerTest
import doobie.implicits.*
import doobie.implicits._
import io.circe.optics.JsonPath.root
import io.laserdisc.mysql.binlog.database
import io.laserdisc.mysql.binlog.config.BinLogConfigOps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.github.shyiko.mysql.binlog.BinaryLogClient
import com.github.shyiko.mysql.binlog.event.{EventHeaderV4, EventType}
import db.MySqlContainerTest
import doobie.hikari.HikariTransactor
import doobie.implicits.*
import doobie.implicits._
import io.laserdisc.mysql.binlog.config.BinLogConfigOps
import io.laserdisc.mysql.binlog.database
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package io.laserdisc.mysql.binlog.stream

import cats.effect.unsafe.implicits.global
import cats.effect.{IO, Resource}
import cats.implicits.*
import cats.implicits._
import com.dimafeng.testcontainers.ForAllTestContainer
import com.github.shyiko.mysql.binlog.BinaryLogClient
import db.MySqlContainerTest
import doobie.hikari.HikariTransactor
import doobie.implicits.*
import doobie.implicits._
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger
import io.laserdisc.mysql.binlog.database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.laserdisc.mysql.binlog.stream

import doobie.ConnectionIO
import doobie.implicits.*
import doobie.implicits._
import doobie.util.update.Update

case class Sku(id: Int, sku: String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.laserdisc.mysql.binlog.stream

import _root_.io.circe.optics.JsonPath.*
import _root_.io.circe.optics.JsonPath._
import _root_.io.circe.Json
import _root_.io.laserdisc.mysql.binlog.*
import com.github.shyiko.mysql.binlog.event.*
import _root_.io.laserdisc.mysql.binlog._
import com.github.shyiko.mysql.binlog.event._
import org.scalatest.OptionValues
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down
Loading

0 comments on commit 9b12932

Please sign in to comment.