mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
* Add .scalafmt.conf
* Adopt quill for database access
* Removed postgresql-async
* Refactored all instances of database access
* Creating duplicate characters of the same account is no longer possible
* Rewrote large parts of LoginSessionActor
* Implement migrations
* Move overrides into subdirectory
* Make usernames case insensitive
* Use LOWER(?) comparison instead of storing lowercased username
* import scala.util.{Success, Failure}
* Add config and joda-time dependencies
* Add sbt-scalafmt
* Use defaultWithAlign scalafmt preset
* Format all
* Add scalafix
* Remove unused imports
* Don't lowercase username when inserting
* Update readme
* Listen on worldserver.Hostname address
* Remove database test on startup
It could fail when the global thread pool is busy loading zone
maps. Migrations run on the main thread and also serve the
purpose of verifying the database configuration so it's fine to
remove the test altogether.
* Refactor chat message handlers, zones
What started as a small change to how zones are stored turned
into a pretty big effort of refactoring the chat message handler.
The !hack command was removed, the /capturebase commandwas added.
* Expose db ports in docker-compose.yml
* Silence property override log
* Rework configuration
* Unify configuration using the typesafe.config library
* Add configuration option for public address
* Configuration is now loaded from application.conf rather than worldserver.ini
* Refactor PsLogin and remove unnecessary logging
* Move pslogin into net.psforever.pslogin namespace
* Fix coverage
67 lines
2 KiB
Scala
67 lines
2 KiB
Scala
package akka.actor
|
|
|
|
// Taken from https://medium.com/hootsuite-engineering/logging-contextual-info-in-an-asynchronous-scala-application-8ea33bfec9b3
|
|
|
|
import akka.util.Timeout
|
|
import org.slf4j.MDC
|
|
|
|
import scala.concurrent.Future
|
|
|
|
trait MDCContextAware extends Actor with ActorLogging {
|
|
import MDCContextAware._
|
|
|
|
// This is why this needs to be in package akka.actor
|
|
override protected[akka] def aroundReceive(receive: Actor.Receive, msg: Any): Unit = {
|
|
val orig = MDC.getCopyOfContextMap
|
|
try {
|
|
msg match {
|
|
case mdcObj @ MdcMsg(mdc, origMsg) =>
|
|
if (mdc != null)
|
|
MDC.setContextMap(mdc)
|
|
else
|
|
MDC.clear()
|
|
super.aroundReceive(receive, origMsg)
|
|
case _ =>
|
|
super.aroundReceive(receive, msg)
|
|
}
|
|
} finally {
|
|
if (orig != null)
|
|
MDC.setContextMap(orig)
|
|
else
|
|
MDC.clear()
|
|
}
|
|
}
|
|
}
|
|
|
|
object MDCContextAware {
|
|
private case class MdcMsg(mdc: java.util.Map[String, String], msg: Any)
|
|
|
|
object Implicits {
|
|
|
|
/**
|
|
* Add two new methods that allow MDC info to be passed to MDCContextAware actors.
|
|
*
|
|
* Do NOT use these methods to send to actors that are not MDCContextAware.
|
|
*/
|
|
implicit class ContextLocalAwareActorRef(val ref: ActorRef) extends AnyVal {
|
|
|
|
import akka.pattern.ask
|
|
|
|
/**
|
|
* Send a message to an actor that is MDCContextAware - it will propagate
|
|
* the current MDC values. Note: we MUST capture the ActorContext in order for senders
|
|
* to be correct! This was a bug from the original author.
|
|
*/
|
|
def !>(msg: Any)(implicit context: ActorContext): Unit =
|
|
ref.tell(MdcMsg(MDC.getCopyOfContextMap, msg), context.self)
|
|
|
|
/**
|
|
* "Ask" an actor that is MDCContextAware for something - it will propagate
|
|
* the current MDC values
|
|
*/
|
|
def ?>(msg: Any)(implicit context: ActorContext, timeout: Timeout): Future[Any] =
|
|
ref.ask(MdcMsg(MDC.getCopyOfContextMap, msg), context.self)
|
|
}
|
|
}
|
|
}
|