Skip to content

Commit

Permalink
Create download-batch target
Browse files Browse the repository at this point in the history
Summary: Create a separate `DownloadBatch.hs` module for internal and oss build (as internal one will download batch from cas)

Reviewed By: donsbot

Differential Revision: D69668663

fbshipit-source-id: e5c2af667ea7f17091f0a88178a422eb1988ad87
  • Loading branch information
iamirzhan authored and facebook-github-bot committed Feb 20, 2025
1 parent dfd6628 commit 0de1287
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions glean.cabal.in
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ library stubs
Glean.BuildInfo
Glean.Datasource.Scribe.Write
Glean.Init
Glean.Server.DownloadBatch
Glean.Server.PublishShards
Glean.Index
Glean.Username
Expand Down
5 changes: 3 additions & 2 deletions glean/db/Glean/Database/Writes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
18 changes: 18 additions & 0 deletions glean/github/Glean/Server/DownloadBatch.hs
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 0de1287

Please sign in to comment.