|
8 | 8 |
|
9 | 9 | {-# LANGUAGE ApplicativeDo, CPP #-} |
10 | 10 | module Glean.Database.Config ( |
| 11 | + -- * DataStore |
11 | 12 | DataStore(..), |
12 | 13 | fileDataStore, |
13 | 14 | tmpDataStore, |
14 | 15 | memoryDataStore, |
| 16 | + |
| 17 | + -- * Config, and options parser |
| 18 | + options, |
15 | 19 | Config(..), |
| 20 | + DebugFlags(..), |
| 21 | + |
| 22 | + -- * Finding and parsing the schema |
16 | 23 | ServerConfig.SchemaLocation(..), |
17 | 24 | showSchemaLocation, |
18 | 25 | schemaLocation, |
19 | 26 | schemaLocationOption, |
20 | | - DebugFlags(..), |
21 | | - options, |
22 | 27 | processSchema, |
23 | 28 | processSchemaCached, |
24 | 29 | processOneSchema, |
25 | 30 | SchemaIndex(..), |
26 | 31 | schemaForSchemaId, |
27 | 32 | ProcessedSchema(..), |
28 | | - schemaSourceIndexConfig, |
29 | 33 | catSchemaFiles, |
30 | 34 | schemaLocationToSource, |
31 | | - schemaLocationFiles, |
32 | | - schemaSourceFilesFromDir, |
33 | | - schemaSourceDir, |
34 | | - schemaSourceFile, |
35 | | - schemaSourceIndexFile, |
36 | 35 | parseSchemaDir, |
37 | 36 | parseSchemaIndex, |
38 | | - -- testing |
| 37 | + loadSchemaIndex, |
| 38 | + |
| 39 | + -- * Testing only |
| 40 | + |
| 41 | + -- if you're using these somewhere other than a test, |
| 42 | + -- you should probably be using something from the API above instead. |
39 | 43 | processSchemaForTesting, |
| 44 | + schemaLocationFiles, |
| 45 | + schemaSourceDir, |
40 | 46 | ) where |
41 | 47 |
|
42 | 48 | import Control.Exception |
@@ -426,6 +432,16 @@ schemaLocation cfg server_cfg = do |
426 | 432 | other -> |
427 | 433 | return other |
428 | 434 |
|
| 435 | +-- | Find and load the SchemaIndex, taking into account command line |
| 436 | +-- flags, the ServerConfig, and the cfgSchemaHook. This is a |
| 437 | +-- convenience function used by the CLI. |
| 438 | +loadSchemaIndex :: ConfigProvider c => Config -> c -> IO SchemaIndex |
| 439 | +loadSchemaIndex cfg cfgAPI = do |
| 440 | + serverConfig <- ThriftSource.load cfgAPI (cfgServerConfig cfg) |
| 441 | + loc <- schemaLocation cfg serverConfig |
| 442 | + let (schemaSource, _) = cfgSchemaHook cfg loc |
| 443 | + ThriftSource.load cfgAPI schemaSource |
| 444 | + |
429 | 445 | showSchemaLocation :: ServerConfig.SchemaLocation -> String |
430 | 446 | showSchemaLocation = \case |
431 | 447 | ServerConfig.SchemaLocation_dir d -> "dir:" <> Text.unpack d |
|
0 commit comments