Skip to content

Commit

Permalink
Use unleash-client-haskell-core 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evenbrenden committed Jan 25, 2023
1 parent a39d5a2 commit 6071600
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
unleash-client-haskell-core.url =
"github:finn-no/unleash-client-haskell-core?ref=0.6.6";
"github:finn-no/unleash-client-haskell-core?ref=0.7.0";
};
outputs =
{ self, nixpkgs, flake-compat, flake-utils, unleash-client-haskell-core }:
Expand Down
8 changes: 4 additions & 4 deletions src/Unleash/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ registerClient config = do
started = now,
intervalSeconds = config.metricsPushIntervalInSeconds
}
liftIO $ void <$> register config.httpClientEnvironment Nothing registrationPayload
void <$> register config.httpClientEnvironment Nothing registrationPayload

-- Fetches the most recent feature toggle set from the Unleash server
-- Meant to be run every statePollIntervalInSeconds
-- Non-blocking
pollState :: MonadIO m => Config -> m (Either ClientError ())
pollState config = do
eitherFeatures <- liftIO $ getAllClientFeatures config.httpClientEnvironment Nothing
eitherFeatures <- getAllClientFeatures config.httpClientEnvironment Nothing
either (const $ pure ()) (void . updateState config.state) eitherFeatures
pure . void $ eitherFeatures
where
updateState state value = do
isUpdated <- liftIO $ tryPutMVar state value
liftIO $ unless isUpdated . void $ swapMVar state value
liftIO . unless isUpdated . void $ swapMVar state value

-- Pushes metrics to the Unleash server
-- Meant to be run every metricsPushIntervalInSeconds
Expand All @@ -100,7 +100,7 @@ pushMetrics config = do
stop = now,
toggles = bucket
}
liftIO $ void <$> sendMetrics config.httpClientEnvironment Nothing metricsPayload
void <$> sendMetrics config.httpClientEnvironment Nothing metricsPayload

-- Checks if a feature is enabled or not
-- Blocks until first feature toggle set is received
Expand Down

0 comments on commit 6071600

Please sign in to comment.