Skip to content

Commit

Permalink
Add string details client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcardell committed May 10, 2024
1 parent 41c3225 commit 4e67d71
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object EvaluationDetails {
flagKey = flagKey,
value = resolution.value,
errorCode = resolution.errorCode,
errorMessage = errorMessage.errorMessage,
errorMessage = resolution.errorMessage,
reason = resolution.reason,
variant = resolution.variant,
metadata = resolution.metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ trait FeatureClient[F[_]] {
options: EvaluationOptions
): F[String]

def getStringDetails(
flagKey: String,
default: String
): F[EvaluationDetails[String]]
def getStringDetails(
flagKey: String,
default: String,
context: EvaluationContext
): F[EvaluationDetails[String]]
def getStringDetails(
flagKey: String,
default: String,
context: EvaluationContext,
options: EvaluationOptions
): F[EvaluationDetails[String]]

def getIntValue(flagKey: String, default: Int): F[Int]
def getIntValue(
flagKey: String,
Expand Down Expand Up @@ -196,14 +212,32 @@ protected final class OpenFeatureClient[F[_]: Monad](
context: EvaluationContext,
options: EvaluationOptions
): F[String] =
provider
.resolveStringValue(
flagKey,
default,
clientEvaluationContext ++ context
)
getStringDetails(flagKey, default, context, EvaluationOptions.Defaults)
.map(_.value)

override def getStringDetails(
flagKey: String,
default: String
): F[EvaluationDetails[String]] =
getStringDetails(flagKey, default, EvaluationContext.empty)

override def getStringDetails(
flagKey: String,
default: String,
context: EvaluationContext
): F[EvaluationDetails[String]] =
getStringDetails(flagKey, default, context, EvaluationOptions.Defaults)

override def getStringDetails(
flagKey: String,
default: String,
context: EvaluationContext,
options: EvaluationOptions
): F[EvaluationDetails[String]] =
provider
.resolveStringValue(flagKey, default, clientEvaluationContext ++ context)
.map(EvaluationDetails[String](flagKey, _))

override def getIntValue(flagKey: String, default: Int): F[Int] =
getIntValue(flagKey, default, EvaluationContext.empty)

Expand Down

0 comments on commit 4e67d71

Please sign in to comment.