diff --git a/flake.lock b/flake.lock index 4d5dd803..37bb315c 100644 --- a/flake.lock +++ b/flake.lock @@ -370,11 +370,11 @@ "tinylog": "tinylog" }, "locked": { - "lastModified": 1734428345, - "narHash": "sha256-Nbss1aAIfrgNMinY0AOfaOa8EUXWhAxHrw7Fhyb55d0=", + "lastModified": 1734612525, + "narHash": "sha256-DPW2S5NRUFA1y8x4j7+GIoadQqt2bebvnRSSbqYSKzw=", "owner": "nammayatri", "repo": "euler-hs", - "rev": "bccffdbc6c27e9ed648a1abb95f288763cff6bcc", + "rev": "7a5642f903349466b30582896ff11de93a7ce880", "type": "github" }, "original": { diff --git a/lib/mobility-core/src/Kernel/Beam/Functions.hs b/lib/mobility-core/src/Kernel/Beam/Functions.hs index 7ef6ef3b..91fb759c 100644 --- a/lib/mobility-core/src/Kernel/Beam/Functions.hs +++ b/lib/mobility-core/src/Kernel/Beam/Functions.hs @@ -30,6 +30,11 @@ module Kernel.Beam.Functions findOneWithKVRedis, logQueryData, findAllFromKvRedis, + createWithKVWithOptions, + createWithKVSchedulerWithOptions, + updateWithKVWithOptions, + updateWithKVSchedulerWithOptions, + updateOneWithKVWithOptions, ) where @@ -102,7 +107,8 @@ meshConfig = kvHardKilled = True, cerealEnabled = False, tableShardModRange = (0, 128), - redisKeyPrefix = "" + redisKeyPrefix = "", + forceDrainToDB = False } runInReplica :: (L.MonadFlow m, Log m) => m a -> m a @@ -415,6 +421,18 @@ updateWithKV :: updateWithKV setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do updateInternal updatedMeshConfig setClause whereClause +updateWithKVWithOptions :: + forall table m r. + (BeamTableFlow table m, EsqDBFlow m r) => + Maybe Integer -> + Bool -> + [Set Postgres table] -> + Where Postgres table -> + m () +updateWithKVWithOptions ttl forceDrain setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do + let updatedMeshConfig' = updatedMeshConfig {redisTtl = fromMaybe (redisTtl updatedMeshConfig) ttl, forceDrainToDB = forceDrain} + updateInternal updatedMeshConfig' setClause whereClause + updateWithKVScheduler :: forall table m r. (BeamTableFlow table m, EsqDBFlow m r) => @@ -424,6 +442,18 @@ updateWithKVScheduler :: updateWithKVScheduler setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do updateInternal updatedMeshConfig setClause whereClause +updateWithKVSchedulerWithOptions :: + forall table m r. + (BeamTableFlow table m, EsqDBFlow m r) => + Maybe Integer -> + Bool -> + [Set Postgres table] -> + Where Postgres table -> + m () +updateWithKVSchedulerWithOptions ttl forceDrain setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do + let updatedMeshConfig' = updatedMeshConfig {redisTtl = fromMaybe (redisTtl updatedMeshConfig) ttl, forceDrainToDB = forceDrain} + updateInternal updatedMeshConfig' setClause whereClause + -- updateOne -- updateOneWithKV :: @@ -435,6 +465,18 @@ updateOneWithKV :: updateOneWithKV setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do updateOneInternal updatedMeshConfig setClause whereClause +updateOneWithKVWithOptions :: + forall table m r. + (BeamTableFlow table m, EsqDBFlow m r) => + Maybe Integer -> + Bool -> + [Set Postgres table] -> + Where Postgres table -> + m () +updateOneWithKVWithOptions ttl forceDrain setClause whereClause = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do + let updatedMeshConfig' = updatedMeshConfig {redisTtl = fromMaybe (redisTtl updatedMeshConfig) ttl, forceDrainToDB = forceDrain} + updateOneInternal updatedMeshConfig' setClause whereClause + -- create -- createWithKV :: @@ -448,6 +490,20 @@ createWithKV :: createWithKV a = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do createInternal updatedMeshConfig toTType' a +createWithKVWithOptions :: + forall table m r a. + ( BeamTableFlow table m, + EsqDBFlow m r, + ToTType' (table Identity) a + ) => + Maybe Integer -> + Bool -> + a -> + m () +createWithKVWithOptions ttl forceDrain a = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do + let updatedMeshConfig' = updatedMeshConfig {redisTtl = fromMaybe (redisTtl updatedMeshConfig) ttl, forceDrainToDB = forceDrain} + createInternal updatedMeshConfig' toTType' a + createWithKVScheduler :: forall table m r a. ( BeamTableFlow table m, @@ -459,6 +515,20 @@ createWithKVScheduler :: createWithKVScheduler a = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do createInternal updatedMeshConfig toTType'' a +createWithKVSchedulerWithOptions :: + forall table m r a. + ( BeamTableFlow table m, + EsqDBFlow m r, + ToTType'' (table Identity) a + ) => + Maybe Integer -> + Bool -> + a -> + m () +createWithKVSchedulerWithOptions ttl forceDrain a = withUpdatedMeshConfig (Proxy @table) $ \updatedMeshConfig -> do + let updatedMeshConfig' = updatedMeshConfig {redisTtl = fromMaybe (redisTtl updatedMeshConfig) ttl, forceDrainToDB = forceDrain} + createInternal updatedMeshConfig' toTType'' a + -- delete -- deleteWithKV ::