-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
take revision value into account when deleting DurableState (#156)
* take revision value into account when deleting add test add tests scalafmt update test Update DurableStateQueries.scala scalafmt * temporarily throw DurableStateStoreException * Update JdbcDurableStateStore.scala * rework exceptions * Update configuration.md * Update configuration.md * Update JdbcDurableStateSpec.scala * uptake apache/pekko#1271 * scalafmt * Update JdbcDurableStateSpec.scala * try to fix test * Update DurableStateExceptionSupport.scala * refactor * use parasitic context * apply review suggestions * review change * Update JdbcDurableStateStore.scala * revert doc change * Update JdbcDurableStateStore.scala
- Loading branch information
Showing
4 changed files
with
125 additions
and
11 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
48 changes: 48 additions & 0 deletions
48
...scala/org/apache/pekko/persistence/jdbc/state/scaladsl/DurableStateExceptionSupport.scala
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,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.pekko.persistence.jdbc.state.scaladsl | ||
|
||
import java.lang.invoke.{ MethodHandles, MethodType } | ||
|
||
import scala.util.Try | ||
|
||
/** | ||
* INTERNAL API | ||
* | ||
* Support for creating a `DeleteRevisionException`if the class is | ||
* available on the classpath. Pekko 1.0 does not have this class, but | ||
* it is added in Pekko 1.1. | ||
*/ | ||
private[scaladsl] object DurableStateExceptionSupport { | ||
val DeleteRevisionExceptionClass = | ||
"org.apache.pekko.persistence.state.exception.DeleteRevisionException" | ||
|
||
private def exceptionClassOpt: Option[Class[_]] = | ||
Try(Class.forName(DeleteRevisionExceptionClass)).toOption | ||
|
||
private val constructorOpt = exceptionClassOpt.map { clz => | ||
val mt = MethodType.methodType(classOf[Unit], classOf[String]) | ||
MethodHandles.publicLookup().findConstructor(clz, mt) | ||
} | ||
|
||
def createDeleteRevisionExceptionIfSupported(message: String): Option[Exception] = | ||
constructorOpt.map { constructor => | ||
constructor.invoke(message).asInstanceOf[Exception] | ||
} | ||
|
||
} |
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