Skip to content

Commit

Permalink
[feature] DbGen: Export dbgen's mongo setup for use by backup code
Browse files Browse the repository at this point in the history
  • Loading branch information
nrs135 committed Jul 8, 2014
1 parent 7695ba4 commit 5b89fa6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/stdlib/database/mongo/db.opa
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ Then use 'opa --db-remote' instead of '--db-local'.
(auth, (Text.to_string(host), port))
parser seeds={Rule.parse_list(seed_parser, Rule.of_string(","))} -> f(seeds)

dbargs = Mutable.make((("",0),{none}):((string,int),
option({kind:option({remote:{auth:list(Mongo.auth);
seeds: list((string,int))}} /
{local:{path:string}});
name:string})))

open(name:string, host, port) =
seed = (host ? "localhost", port ? 27017)
(suffix, msg) = match name with
Expand Down Expand Up @@ -689,6 +695,7 @@ Then use 'opa --db-remote' instead of '--db-local'.
},
]
})
do dbargs.set((seed,{some=args})) // We need access to this for backups
match args.kind with
| {some = ~{remote}} -> open_remote(args.name, remote, seed)
| {some = ~{local}} -> open_local(args.name, local, seed)
Expand All @@ -711,6 +718,7 @@ Then use 'opa --db-remote' instead of '--db-local'.
}}

open = Init.open
dbargs = Init.dbargs

@package drop(db:DbMongo.t) =
db = db.get()
Expand Down

0 comments on commit 5b89fa6

Please sign in to comment.