Skip to content

Commit

Permalink
TIG-1209 (Part 1): Clean up DocumentGenerator API (mongodb#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtimmons authored Mar 18, 2019
1 parent 4de7565 commit 325eec1
Show file tree
Hide file tree
Showing 17 changed files with 537 additions and 340 deletions.
13 changes: 7 additions & 6 deletions scripts/create-new-actor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,20 @@ create_impl_text() {
echo "#include <gennylib/Cast.hpp>"
echo "#include <gennylib/ExecutionStrategy.hpp>"
echo "#include <gennylib/context.hpp>"
echo "#include <value_generators/value_generators.hpp>"
echo ""
echo "#include <value_generators/DocumentGenerator.hpp>"
echo ""
echo ""
echo "namespace genny::actor {"
echo ""
echo "struct ${actor_name}::PhaseConfig {"
echo " mongocxx::collection collection;"
echo " value_generators::UniqueExpression documentExpr;"
echo " DocumentGenerator documentExpr;"
echo " ExecutionStrategy::RunOptions options;"
echo ""
echo " PhaseConfig(PhaseContext& phaseContext, const mongocxx::database& db)"
echo " PhaseConfig(PhaseContext& phaseContext, const mongocxx::database& db, DefaultRandom& rng)"
echo " : collection{db[phaseContext.get<std::string>(\"Collection\")]},"
echo " documentExpr{value_generators::Expression::parseOperand(phaseContext.get(\"Document\"))},"
echo " documentExpr{DocumentGenerator::create(phaseContext.get(\"Document\"), rng)},"
echo " options{ExecutionStrategy::getOptionsFrom(phaseContext, \"ExecutionsStrategy\")} {}"
echo "};"
echo ""
Expand All @@ -151,7 +152,7 @@ create_impl_text() {
echo " _strategy.run("
echo " [&](metrics::OperationContext& ctx) {"
echo " // TODO: main logic"
echo " auto document = config->documentExpr->evaluate(_rng).getDocument();"
echo " auto document = config->documentExpr();"
echo " BOOST_LOG_TRIVIAL(info) << \" ${actor_name} Inserting \""
echo " << bsoncxx::to_json(document.view());"
echo " config->collection.insert_one(document.view());"
Expand All @@ -168,7 +169,7 @@ create_impl_text() {
echo " _rng{context.workload().createRNG()},"
echo " _strategy{context.operation(\"insert\", ${actor_name}::id())},"
echo " _client{std::move(context.client())},"
echo " _loop{context, (*_client)[context.get<std::string>(\"Database\")]} {}"
echo " _loop{context, (*_client)[context.get<std::string>(\"Database\")], _rng} {}"
echo ""
echo "namespace {"
echo "auto register${actor_name} = Cast::registerDefault<${actor_name}>();"
Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/include/cast_core/actors/CrudActor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <gennylib/context.hpp>

#include <value_generators/DefaultRandom.hpp>
#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/include/cast_core/actors/Insert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <gennylib/PhaseLoop.hpp>
#include <gennylib/context.hpp>

#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/include/cast_core/actors/InsertRemove.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <gennylib/PhaseLoop.hpp>
#include <gennylib/context.hpp>

#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/include/cast_core/actors/Loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <metrics/metrics.hpp>

#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <gennylib/PhaseLoop.hpp>
#include <gennylib/context.hpp>
#include <metrics/metrics.hpp>
#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <metrics/metrics.hpp>

#include <value_generators/value_generators.hpp>
#include <value_generators/DocumentGenerator.hpp>

namespace genny::actor {

Expand Down
Loading

0 comments on commit 325eec1

Please sign in to comment.