-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e915c87
commit 3d65d82
Showing
5 changed files
with
49 additions
and
17 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
19 changes: 14 additions & 5 deletions
19
call-logging/posix/src/dev/programadorthi/routing/callloging/MDC.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 |
---|---|---|
@@ -1,21 +1,30 @@ | ||
package dev.programadorthi.routing.callloging | ||
|
||
import io.ktor.util.collections.ConcurrentMap | ||
|
||
public actual object MDC { | ||
// TODO: Well, how to implement MDC in native? | ||
// TODO: Well, how to implement MDC Thread Local map in native? | ||
private val current = ConcurrentMap<String, String>() | ||
|
||
public actual fun clear() { | ||
// no-op for now | ||
current.clear() | ||
} | ||
|
||
public actual fun get(key: String): String? { | ||
return current[key] | ||
} | ||
|
||
public actual fun getCopyOfContextMap(): Map<String, String>? { | ||
return null | ||
return current.toMap() | ||
} | ||
|
||
public actual fun remove(key: String) { | ||
// no-op for now | ||
current.remove(key) | ||
} | ||
|
||
public actual fun setContextMap(contextMap: Map<String, String>?) { | ||
// no-op for now | ||
val other = contextMap ?: return | ||
current.clear() | ||
current.putAll(other) | ||
} | ||
} |
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