diff --git a/glean.cabal.in b/glean.cabal.in index 3c9a4e06e..dd4c0641d 100644 --- a/glean.cabal.in +++ b/glean.cabal.in @@ -194,6 +194,7 @@ library stubs Glean.BuildInfo Glean.Datasource.Scribe.Write Glean.Init + Glean.Server.DownloadBatch Glean.Server.PublishShards Glean.Index Glean.Username diff --git a/glean/db/Glean/Database/Writes.hs b/glean/db/Glean/Database/Writes.hs index 4f82e090e..a988a548a 100644 --- a/glean/db/Glean/Database/Writes.hs +++ b/glean/db/Glean/Database/Writes.hs @@ -80,6 +80,7 @@ import Glean.Database.Types import qualified Glean.RTS.Foreign.Subst as Subst import Glean.RTS.Foreign.Ownership (DefineOwnership) import qualified Glean.ServerConfig.Types as ServerConfig +import Glean.Server.DownloadBatch import Glean.Types as Thrift hiding (Database) import Glean.Write.JSON import Glean.Util.Metric @@ -377,11 +378,11 @@ enqueueBatchDescriptor env repo enqueueBatch waitPolicy = do traceMsg (envTracer env) (GleanTraceEnqueue repo EnqueueBatchDescriptor 0) $ do handle <- UUID.toText <$> UUID.nextRandom - _ <- case enqueueBatch of + descriptor <- case enqueueBatch of Thrift.EnqueueBatch_descriptor descriptor -> return descriptor Thrift.EnqueueBatch_EMPTY -> throwIO $ Thrift.Exception "empty batch" write <- enqueueWrite env repo 0 Nothing False $ - throwIO $ Exception "not implemented" + writeContentFromBatch <$> downloadBatch descriptor when (waitPolicy == Thrift.EnqueueBatchWaitPolicy_Remember) $ rememberWrite env handle write return $ def { enqueueBatchResponse_handle = handle } diff --git a/glean/github/Glean/Server/DownloadBatch.hs b/glean/github/Glean/Server/DownloadBatch.hs new file mode 100644 index 000000000..94e8637f2 --- /dev/null +++ b/glean/github/Glean/Server/DownloadBatch.hs @@ -0,0 +1,18 @@ +{- + Copyright (c) Meta Platforms, Inc. and affiliates. + All rights reserved. + + This source code is licensed under the BSD-style license found in the + LICENSE file in the root directory of this source tree. +-} + +module Glean.Server.DownloadBatch + ( downloadBatch + ) where + +import Glean.Types as Thrift +import Control.Exception + +downloadBatch :: Thrift.BatchDescriptor -> IO Thrift.Batch +downloadBatch _ = throwIO $ + Thrift.Exception "couldn't download batch from location"