Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol v1 #18

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
image: sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.12.19
steps:
- uses: actions/checkout@v4
- run: sbt headerCheckAll
- run: sbt headerCheckAll javafmtCheckAll scalafmtCheckAll
test:
runs-on: self-hosted
container:
Expand Down
152 changes: 24 additions & 128 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,136 +1,32 @@
version = 2.7.5
version = "3.8.3"
runner.dialect = "scala213"
style = "IntelliJ"
maxColumn = 120

optIn.forceBlankLineBeforeDocstring = true
trailingCommas = "never"

align {
openParenCallSite = false
openParenDefnSite = false
preset=some
stripMargin = false
tokens = []
}

assumeStandardLibraryStripMargin = true
binPack.parentConstructors = "never"

continuationIndent {
callSite = 2
ctorSite = 4
defnSite = 4
extendSite = 4
}

indentOperator.include = "^.*=$"
rewrite.rules = [Imports, RedundantParens, SortModifiers]
rewrite.imports.sort = ascii
rewrite.imports.groups = [
["java.?\\..*"],
["sbt\\..*"],
["scala\\..*"],
["org\\..*"],
["com\\..*"],
]
newlines.alwaysBeforeElseAfterCurlyIf = false
danglingParentheses {
ctrlSite = true
defnSite = true
}


docstrings.style = "Asterisk" // JavaDoc
includeCurlyBraceInSelectChains = true
includeNoParensInSelectChains = false

literals {
double = "Lower"
float = "Lower"
hexDigits = "Lower"
hexPrefix = "Lower"
long = "Upper"
}

newlines {
afterCurlyLambdaParams = squash
afterCurlyLambdaParams=squash
alwaysBeforeElseAfterCurlyIf = false
beforeCurlyLambdaParams = multilineWithCaseOnly
beforeMultiline = fold
beforeMultilineDef = false
implicitParamListModifierPrefer = before
}

rewrite {
redundantBraces {
generalExpressions = false
ifElseExpressions = false
methodBodies = false
parensForOneLineApply = true
stringInterpolation = true
}
rules = [
RedundantBraces,
RedundantParens,
SortModifiers,
SortImports
]
redundantBraces {
generalExpressions = false
methodBodies = false
ifElseExpressions = false
parensForOneLineApply = true
stringInterpolation = true
}
sortModifiers {
order = [
"implicit",
"final",
"sealed",
"abstract",
"override",
"private",
"protected",
"lazy"
]
}
}

continuationIndent {
callSite = 2
defnSite = 4
ctorSite = 4
extendSite = 4
callSite = false
defnSite = false
}

align {
preset=some
tokens = []
openParenCallSite = false
openParenDefnSite = false
preset = some
stripMargin = false
tokens = []
}

danglingParentheses {
defnSite = true
ctrlSite = true
openParenDefnSite = false
openParenCallSite = false
}

docstrings.style = Asterisk
docstrings.wrap = fold
optIn.configStyleArguments = false
spaces {
afterKeywordBeforeParen = true
afterSymbolicDefs = false
beforeContextBoundColon = "Never"
inByNameTypes = true
inParentheses = false
neverAroundInfixTypes = []
afterKeywordBeforeParen = true
inByNameTypes = true
afterSymbolicDefs = false
}

literals {
long = "Upper"
float = "Lower"
double = "Lower"
hexPrefix = "Lower"
hexDigits = "Lower"
}

docstrings {
style = "Asterisk" // JavaDoc
}

binPack {
parentConstructors = "Never"
inImportCurlyBraces = false
}
continuationIndent.defnSite = 4
runner.optimizer.maxVisitsPerToken = 15000
133 changes: 64 additions & 69 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import sbt.Keys._
import sbt._

import java.nio.file.Paths
import sbt.*
import sbt.Keys.*

ThisBuild / credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"raw-labs",
sys.env.getOrElse("GITHUB_TOKEN", "")
)
sys.env.getOrElse("GITHUB_TOKEN", ""))

lazy val commonSettings = Seq(
homepage := Some(url("https://www.raw-labs.com/")),
Expand All @@ -18,68 +15,40 @@ lazy val commonSettings = Seq(
// Use cached resolution of dependencies
// http://www.scala-sbt.org/0.13/docs/Cached-Resolution.html
updateOptions := updateOptions.in(Global).value.withCachedResolution(true),
resolvers += "RAW Labs GitHub Packages" at "https://maven.pkg.github.com/raw-labs/_"
)
resolvers += "RAW Labs GitHub Packages" at "https://maven.pkg.github.com/raw-labs/_")

lazy val buildSettings = Seq(scalaVersion := "2.13.15")

lazy val buildSettings = Seq(
scalaVersion := "2.12.18",
javacOptions ++= Seq(
"-source",
"21",
"-target",
"21"
),
scalacOptions ++= Seq(
"-feature",
"-unchecked",
// When compiling in encrypted drives in Linux, the max size of a name is reduced to around 140
// https://unix.stackexchange.com/a/32834
"-Xmax-classfile-name",
"140",
"-deprecation",
"-Xlint:-stars-align,_",
"-Ywarn-dead-code",
"-Ywarn-macros:after", // Fix for false warning of unused implicit arguments in traits/interfaces.
"-Ypatmat-exhaust-depth",
"160"
)
)
lazy val chronicleFlags = Seq(
"--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED",
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
"--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens=java.base/java.io=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED")

lazy val compileSettings = Seq(
Compile / doc / sources := Seq.empty,
Compile / packageDoc / mappings := Seq(),
Compile / packageSrc / publishArtifact := true,
Compile / packageDoc / publishArtifact := false,
Compile / packageBin / packageOptions += Package.ManifestAttributes(
"Automatic-Module-Name" -> name.value.replace('-', '.')
),
// Ensure Java annotations get compiled first, so that they are accessible from Scala.
compileOrder := CompileOrder.JavaThenScala
)
"Automatic-Module-Name" -> name.value.replace('-', '.')),
// Ensure Java-based DAS SDK code is compiled first, so it is accessible from Scala.
compileOrder := CompileOrder.JavaThenScala,
// Ensure we fork new JVM for run, so we can set JVM flags.
Compile / run / fork := true,
Compile / run / javaOptions ++= chronicleFlags)

lazy val testSettings = Seq(
// Ensuring tests are run in a forked JVM for isolation.
// Ensure we fork new JVM for run, so we can set JVM flags.
Test / fork := true,
// Disabling parallel execution of tests.
//Test / parallelExecution := false,
// Pass system properties starting with "raw." to the forked JVMs.
Test / javaOptions ++= {
import scala.collection.JavaConverters._
val props = System.getProperties
props
.stringPropertyNames()
.asScala
.filter(_.startsWith("raw."))
.map(key => s"-D$key=${props.getProperty(key)}")
.toSeq
},
// Set up heap dump options for out-of-memory errors.
Test / javaOptions ++= Seq(
"-XX:+HeapDumpOnOutOfMemoryError",
s"-XX:HeapDumpPath=${Paths.get(sys.env.getOrElse("SBT_FORK_OUTPUT_DIR", "target/test-results")).resolve("heap-dumps")}"
),
Test / publishArtifact := true
)
Test / javaOptions ++= chronicleFlags,
// Required for publishing test artifacts.
Test / publishArtifact := true)

val isCI = sys.env.getOrElse("CI", "false").toBoolean

Expand All @@ -88,16 +57,11 @@ lazy val publishSettings = Seq(
publish / skip := false,
publishMavenStyle := true,
publishTo := Some(
"GitHub raw-labs Apache Maven Packages" at "https://maven.pkg.github.com/raw-labs/das-server-scala"
),
publishConfiguration := publishConfiguration.value.withOverwrite(isCI)
)
"GitHub raw-labs Apache Maven Packages" at "https://maven.pkg.github.com/raw-labs/das-server-scala"),
publishConfiguration := publishConfiguration.value.withOverwrite(isCI))

lazy val strictBuildSettings = commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq(
scalacOptions ++= Seq(
"-Xfatal-warnings"
)
)
lazy val strictBuildSettings =
commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq(scalacOptions ++= Seq("-Xfatal-warnings"))

lazy val root = (project in file("."))
.enablePlugins(BuildInfoPlugin)
Expand All @@ -108,6 +72,37 @@ lazy val root = (project in file("."))
strictBuildSettings,
publishSettings,
libraryDependencies ++= Seq(
"com.raw-labs" %% "das-sdk-scala" % "0.1.4" % "compile->compile;test->test"
)
)
// Logging
// Using SLF4j as the facade, Logback as the implementation, Loki for log aggregation and with Scala support.
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"ch.qos.logback" % "logback-classic" % "1.5.12",
"org.slf4j" % "slf4j-api" % "2.0.16",
"org.slf4j" % "log4j-over-slf4j" % "2.0.16",
"org.slf4j" % "jcl-over-slf4j" % "2.0.16",
"org.slf4j" % "jul-to-slf4j" % "2.0.16",
"com.github.loki4j" % "loki-logback-appender" % "1.5.2",
// Configuration
"com.typesafe" % "config" % "1.4.3",
// Protocol DAS
"com.raw-labs" %% "protocol-das" % "1.0.0-beta2",
// Akka Streams
"com.typesafe.akka" %% "akka-actor-typed" % "2.8.8",
"com.typesafe.akka" %% "akka-actor" % "2.8.8",
"com.typesafe.akka" %% "akka-stream" % "2.8.8",
"com.typesafe.akka" %% "akka-actor-testkit-typed" % "2.8.8",
"com.typesafe.akka" %% "akka-testkit" % "2.8.8",
// Chronicle Queue (iterator cache)
"net.openhft" % "chronicle-queue" % "5.27ea0",
// SQLite
"org.xerial" % "sqlite-jdbc" % "3.47.1.0",
// Flyway
"org.flywaydb" % "flyway-core" % "11.1.0",
// gRPC Testing
"io.grpc" % "grpc-inprocess" % "1.62.2",
// Web UI
"com.typesafe.akka" %% "akka-http" % "10.5.3",
"com.lihaoyi" %% "scalatags" % "0.13.1",
// Postgres
"org.postgresql" % "postgresql" % "42.7.4" % Test,
// Testing
"org.scalatest" %% "scalatest" % "3.2.19" % Test))
6 changes: 4 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ autoCompilerPlugins := true

addDependencyTreePlugin

libraryDependencies += "commons-io" % "commons-io" % "2.11.0"
//libraryDependencies += "commons-io" % "commons-io" % "2.11.0"

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.8.0")

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/rawlabs/das/sdk/DASException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2024 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package com.rawlabs.das.sdk;

/**
* Top-level Exception. Message contains information that WILL BE shared with the end-user, so
* ensure it does not leak sensitive information.
*/
public class DASException extends RuntimeException {
public DASException(String message) {
super(message);
}

public DASException(String message, Throwable cause) {
super(message, cause);
}
}
Loading