From 24781e05e62f24b60c29db86737d063cae9ebaa3 Mon Sep 17 00:00:00 2001 From: Emmanuel Denloye-Ito Date: Tue, 30 Jan 2024 12:49:30 -0500 Subject: [PATCH] create ES index pt2 --- exec/TXG.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exec/TXG.hs b/exec/TXG.hs index 800f10c..8521dea 100644 --- a/exec/TXG.hs +++ b/exec/TXG.hs @@ -508,6 +508,11 @@ mkElasticSearchRequest esConf version start end rks = do , "timestamp" .= now ] +esPutReq :: MonadIO m => MonadThrow m => Manager -> ElasticSearchConfig -> ChainwebVersion -> m () +esPutReq mgr esConf version = do + esReq <- liftIO $ createElasticsearchIndex esConf version + liftIO $ httpJson mgr esReq + createElasticsearchIndex :: MonadIO m => MonadThrow m => ElasticSearchConfig -> ChainwebVersion -> m HTTP.Request createElasticsearchIndex esConf version = do let indexName :: String @@ -716,8 +721,7 @@ realTransactions config (ChainwebHost h _p2p service) tcut tv distribution = do -- Set up values for running the effect stack. gen <- liftIO createSystemRandom -- create elasticsearch index if ElasticSearchConfig is set - forM_ (elasticSearchConfig config) $ \esConfig -> do - createElasticsearchIndex esConfig (nodeVersion config) + forM_ (elasticSearchConfig config) $ \esConfig -> esPutReq (confManager cfg) esConfig (nodeVersion config) let act = loop (confirmationDepth config) tcut (liftIO randomEnum >>= generateTransactions False (verbose config)) env = set (field @"confKeysets") accountMap cfg stt = TXGState gen tv chains