[{"data":1,"prerenderedAt":5303},["ShallowReactive",2],{"navigation_docs":3,"-sdks-server-ruby":362,"-sdks-server-ruby-surround":5298},[4,10,71,97,267,343],{"title":5,"path":6,"stem":7,"icon":8,"exact":9},"Introduction","\u002F","0.index","i-lucide-book-open",true,{"title":11,"icon":12,"modifiedAt":13,"path":14,"stem":15,"children":16,"page":12},"Getting Started",false,"2026-04-30T19:15:33.000Z","\u002Fgetting-started","1.getting-started",[17,22,27,32,37,42,47,61,66],{"title":18,"path":19,"stem":20,"icon":21},"Quickstart","\u002Fgetting-started\u002Fquickstart","1.getting-started\u002F1.quickstart","i-lucide-fast-forward",{"title":23,"path":24,"stem":25,"icon":26},"Core Concepts","\u002Fgetting-started\u002Fcore-concepts","1.getting-started\u002F2.core-concepts","i-lucide-workflow",{"title":28,"path":29,"stem":30,"icon":31},"Configs Anatomy","\u002Fgetting-started\u002Fconfigs","1.getting-started\u002F3.configs","i-lucide-file-cog",{"title":33,"path":34,"stem":35,"icon":36},"Architecture","\u002Fgetting-started\u002Farchitecture","1.getting-started\u002F4.architecture","i-lucide-layers",{"title":38,"path":39,"stem":40,"icon":41},"JSON Schema Validation","\u002Fgetting-started\u002Fjson-schema-validation","1.getting-started\u002F5.json-schema-validation","i-lucide-braces",{"title":43,"path":44,"stem":45,"icon":46},"Testing Rules","\u002Fgetting-started\u002Ftesting-targeting-rules","1.getting-started\u002F6.testing-targeting-rules","i-lucide-flask-conical",{"title":48,"modifiedAt":49,"icon":50,"defaultOpen":12,"path":51,"stem":52,"children":53},"Experiments","2026-11-10T01:16:18.000Z","i-lucide-flask-round","\u002Fgetting-started\u002Fexperiments","1.getting-started\u002F7.experiments\u002Findex",[54,56],{"title":55,"path":51,"stem":52,"icon":8},"Overview",{"title":57,"path":58,"stem":59,"icon":60},"How results are computed","\u002Fgetting-started\u002Fexperiments\u002Fhow-results-are-computed","1.getting-started\u002F7.experiments\u002F1.how-results-are-computed","i-lucide-sigma",{"title":62,"path":63,"stem":64,"icon":65},"Segments","\u002Fgetting-started\u002Fsegments","1.getting-started\u002F8.segments","i-lucide-squares-intersect",{"title":67,"path":68,"stem":69,"icon":70},"Pricing & Billing","\u002Fgetting-started\u002Fpricing-and-billing","1.getting-started\u002F9.pricing-and-billing","i-lucide-credit-card",{"title":72,"modifiedAt":73,"defaultOpen":9,"path":74,"stem":75,"children":76,"page":12},"Monitoring","2026-09-24T23:33:20.000Z","\u002Fmonitoring","2.monitoring",[77,82,87,92],{"title":78,"path":79,"stem":80,"icon":81},"Activity","\u002Fmonitoring\u002Factivity","2.monitoring\u002F1.activity","i-lucide-activity",{"title":83,"path":84,"stem":85,"icon":86},"Lifecycle","\u002Fmonitoring\u002Flifecycle","2.monitoring\u002F2.lifecycle","i-lucide-recycle",{"title":88,"path":89,"stem":90,"icon":91},"Alerts","\u002Fmonitoring\u002Falerts","2.monitoring\u002F3.alerts","i-lucide-bell",{"title":93,"path":94,"stem":95,"icon":96},"Dynamic Detection","\u002Fmonitoring\u002Fdynamic-detection","2.monitoring\u002F4.dynamic-detection","i-lucide-hat-glasses",{"title":98,"modifiedAt":73,"defaultOpen":9,"path":99,"stem":100,"children":101,"page":12},"SDKs","\u002Fsdks","3.sdks",[102,107,128,153,169,210,262],{"title":103,"path":104,"stem":105,"icon":106},"Available SDKs","\u002Fsdks\u002Favailable-sdks","3.sdks\u002F1.available-sdks","i-lucide-list",{"title":108,"modifiedAt":73,"icon":109,"defaultOpen":12,"path":110,"stem":111,"children":112,"page":12},"Browser SDKs","i-lucide-monitor","\u002Fsdks\u002Fbrowser","3.sdks\u002F2.browser",[113,118,123],{"title":114,"path":115,"stem":116,"icon":117},"Javascript","\u002Fsdks\u002Fbrowser\u002Fjavascript","3.sdks\u002F2.browser\u002F1.javascript","cd-logos-javascript",{"title":119,"path":120,"stem":121,"icon":122},"React","\u002Fsdks\u002Fbrowser\u002Freact","3.sdks\u002F2.browser\u002F2.react","cd-logos-react-light",{"title":124,"path":125,"stem":126,"icon":127},"Vue","\u002Fsdks\u002Fbrowser\u002Fvue","3.sdks\u002F2.browser\u002F3.vue","cd-logos-vue",{"title":129,"modifiedAt":73,"icon":130,"defaultOpen":12,"path":131,"stem":132,"children":133,"page":12},"Mobile SDKs","i-lucide-smartphone","\u002Fsdks\u002Fmobile","3.sdks\u002F3.mobile",[134,138,143,148],{"title":135,"path":136,"stem":137,"icon":122},"React Native","\u002Fsdks\u002Fmobile\u002Freact-native","3.sdks\u002F3.mobile\u002F1.react-native",{"title":139,"path":140,"stem":141,"icon":142},"Flutter","\u002Fsdks\u002Fmobile\u002Fflutter","3.sdks\u002F3.mobile\u002F2.flutter","cd-logos-flutter",{"title":144,"path":145,"stem":146,"icon":147},"Swift","\u002Fsdks\u002Fmobile\u002Fswift","3.sdks\u002F3.mobile\u002F3.swift","cd-logos-swift",{"title":149,"path":150,"stem":151,"icon":152},"Android","\u002Fsdks\u002Fmobile\u002Fandroid","3.sdks\u002F3.mobile\u002F4.android","cd-logos-android",{"title":154,"modifiedAt":73,"icon":155,"defaultOpen":12,"path":156,"stem":157,"children":158,"page":12},"Meta-framework SDKs","i-lucide-monitor-smartphone","\u002Fsdks\u002Fmeta","3.sdks\u002F4.meta",[159,164],{"title":160,"path":161,"stem":162,"icon":163},"Next.js","\u002Fsdks\u002Fmeta\u002Fnextjs","3.sdks\u002F4.meta\u002F1.nextjs","cd-logos-nextjs",{"title":165,"path":166,"stem":167,"icon":168},"Nuxt","\u002Fsdks\u002Fmeta\u002Fnuxt","3.sdks\u002F4.meta\u002F2.nuxt","cd-logos-nuxt",{"title":170,"modifiedAt":73,"icon":171,"defaultOpen":12,"path":172,"stem":173,"children":174,"page":12},"Server SDKs","i-lucide-server","\u002Fsdks\u002Fserver","3.sdks\u002F5.server",[175,180,185,190,195,200,205],{"title":176,"path":177,"stem":178,"icon":179},"Node.js","\u002Fsdks\u002Fserver\u002Fnode-js","3.sdks\u002F5.server\u002F1.node-js","cd-logos-nodejs",{"title":181,"path":182,"stem":183,"icon":184},"Python","\u002Fsdks\u002Fserver\u002Fpython","3.sdks\u002F5.server\u002F2.python","cd-logos-python",{"title":186,"path":187,"stem":188,"icon":189},"Java","\u002Fsdks\u002Fserver\u002Fjava","3.sdks\u002F5.server\u002F3.java","cd-logos-java",{"title":191,"path":192,"stem":193,"icon":194},".NET","\u002Fsdks\u002Fserver\u002Fdotnet","3.sdks\u002F5.server\u002F4.dotnet","cd-logos-dotnet",{"title":196,"path":197,"stem":198,"icon":199},"Go","\u002Fsdks\u002Fserver\u002Fgo","3.sdks\u002F5.server\u002F5.go","cd-logos-go",{"title":201,"path":202,"stem":203,"icon":204},"PHP","\u002Fsdks\u002Fserver\u002Fphp","3.sdks\u002F5.server\u002F6.php","cd-logos-php",{"title":206,"path":207,"stem":208,"icon":209},"Ruby","\u002Fsdks\u002Fserver\u002Fruby","3.sdks\u002F5.server\u002F7.ruby","cd-logos-ruby",{"title":211,"modifiedAt":73,"icon":212,"defaultOpen":12,"path":213,"stem":214,"children":215},"OpenFeature Providers","cd-logos-openfeature","\u002Fsdks\u002Fopenfeature","3.sdks\u002F6.openfeature\u002Findex",[216,217,222,226,230,234,238,242,246,250,254,258],{"title":55,"path":213,"stem":214,"icon":212},{"title":218,"path":219,"stem":220,"icon":212,"icons":221},"Web","\u002Fsdks\u002Fopenfeature\u002Fweb","3.sdks\u002F6.openfeature\u002F1.web",[212,117],{"title":144,"path":223,"stem":224,"icon":212,"icons":225},"\u002Fsdks\u002Fopenfeature\u002Fswift","3.sdks\u002F6.openfeature\u002F2.swift",[212,147],{"title":149,"path":227,"stem":228,"icon":212,"icons":229},"\u002Fsdks\u002Fopenfeature\u002Fandroid","3.sdks\u002F6.openfeature\u002F3.android",[212,152],{"title":139,"path":231,"stem":232,"icon":212,"icons":233},"\u002Fsdks\u002Fopenfeature\u002Fflutter","3.sdks\u002F6.openfeature\u002F4.flutter",[212,142],{"title":176,"path":235,"stem":236,"icon":212,"icons":237},"\u002Fsdks\u002Fopenfeature\u002Fnode-js","3.sdks\u002F6.openfeature\u002F5.node-js",[212,179],{"title":181,"path":239,"stem":240,"icon":212,"icons":241},"\u002Fsdks\u002Fopenfeature\u002Fpython","3.sdks\u002F6.openfeature\u002F6.python",[212,184],{"title":186,"path":243,"stem":244,"icon":212,"icons":245},"\u002Fsdks\u002Fopenfeature\u002Fjava","3.sdks\u002F6.openfeature\u002F7.java",[212,189],{"title":191,"path":247,"stem":248,"icon":212,"icons":249},"\u002Fsdks\u002Fopenfeature\u002Fdotnet","3.sdks\u002F6.openfeature\u002F8.dotnet",[212,194],{"title":196,"path":251,"stem":252,"icon":212,"icons":253},"\u002Fsdks\u002Fopenfeature\u002Fgo","3.sdks\u002F6.openfeature\u002F9.go",[212,199],{"title":201,"path":255,"stem":256,"icon":212,"icons":257},"\u002Fsdks\u002Fopenfeature\u002Fphp","3.sdks\u002F6.openfeature\u002F90.php",[212,204],{"title":206,"path":259,"stem":260,"icon":212,"icons":261},"\u002Fsdks\u002Fopenfeature\u002Fruby","3.sdks\u002F6.openfeature\u002F91.ruby",[212,209],{"title":263,"path":264,"stem":265,"icon":266},"Maven Repository","\u002Fsdks\u002Fmaven-repository","3.sdks\u002F7.maven-repository","i-lucide-package",{"title":268,"modifiedAt":73,"defaultOpen":9,"path":269,"stem":270,"children":271,"page":12},"Integrations","\u002Fintegrations","4.integrations",[272,277,282,287,292,296,301,338],{"title":273,"path":274,"stem":275,"icon":276},"MCP","\u002Fintegrations\u002Fmcp","4.integrations\u002F1.mcp","cd-logos-mcp",{"title":278,"path":279,"stem":280,"icon":281},"Agent Skills","\u002Fintegrations\u002Fagents","4.integrations\u002F2.agents","i-lucide-bot",{"title":283,"path":284,"stem":285,"icon":286},"CLI","\u002Fintegrations\u002Fcli","4.integrations\u002F3.cli","cd-logos-cli",{"title":288,"path":289,"stem":290,"icon":291},"Terraform","\u002Fintegrations\u002Fterraform","4.integrations\u002F4.terraform","cd-logos-terraform",{"title":293,"path":294,"stem":295,"icon":41},"Admin API","\u002Fintegrations\u002Fadmin-api","4.integrations\u002F5.admin-api",{"title":297,"path":298,"stem":299,"icon":300},"Webhooks","\u002Fintegrations\u002Fwebhooks","4.integrations\u002F6.webhooks","i-lucide-webhook",{"title":302,"modifiedAt":303,"icon":304,"defaultOpen":12,"path":305,"stem":306,"children":307},"Analytics","2026-11-08T17:10:01.000Z","i-lucide-chart-line","\u002Fintegrations\u002Fanalytics","4.integrations\u002F7.analytics\u002Findex",[308,310,314,318,322,326,330,334],{"title":55,"path":305,"stem":306,"icon":309},"i-lucide-blocks",{"title":311,"path":312,"stem":313,"icon":304},"Amplitude","\u002Fintegrations\u002Fanalytics\u002Famplitude","4.integrations\u002F7.analytics\u002F1.amplitude",{"title":315,"path":316,"stem":317,"icon":304},"Datadog","\u002Fintegrations\u002Fanalytics\u002Fdatadog","4.integrations\u002F7.analytics\u002F2.datadog",{"title":319,"path":320,"stem":321,"icon":304},"Google Analytics 4","\u002Fintegrations\u002Fanalytics\u002Fga4","4.integrations\u002F7.analytics\u002F3.ga4",{"title":323,"path":324,"stem":325,"icon":304},"Grafana","\u002Fintegrations\u002Fanalytics\u002Fgrafana","4.integrations\u002F7.analytics\u002F4.grafana",{"title":327,"path":328,"stem":329,"icon":304},"Mixpanel","\u002Fintegrations\u002Fanalytics\u002Fmixpanel","4.integrations\u002F7.analytics\u002F5.mixpanel",{"title":331,"path":332,"stem":333,"icon":304},"PostHog","\u002Fintegrations\u002Fanalytics\u002Fposthog","4.integrations\u002F7.analytics\u002F6.posthog",{"title":335,"path":336,"stem":337,"icon":304},"Segment","\u002Fintegrations\u002Fanalytics\u002Fsegment","4.integrations\u002F7.analytics\u002F7.segment",{"title":339,"path":340,"stem":341,"icon":342},"Slack","\u002Fintegrations\u002Fslack","4.integrations\u002F8.slack","i-simple-icons-slack",{"title":344,"modifiedAt":345,"defaultOpen":9,"path":346,"stem":347,"children":348,"page":12},"Migration Guides","2026-10-16T17:57:49.000Z","\u002Fmigration-guides","5.migration-guides",[349,354,358],{"title":350,"path":351,"stem":352,"icon":353},"From LaunchDarkly","\u002Fmigration-guides\u002Flaunchdarkly","5.migration-guides\u002F1.launchdarkly","i-lucide-baggage-claim",{"title":355,"path":356,"stem":357,"icon":353},"From Firebase Remote Config","\u002Fmigration-guides\u002Ffirebase-remote-config","5.migration-guides\u002F2.firebase-remote-config",{"title":359,"path":360,"stem":361,"icon":353},"From Firebase A\u002FB Testing","\u002Fmigration-guides\u002Ffirebase-ab-testing","5.migration-guides\u002F3.firebase-ab-testing",{"id":363,"title":364,"body":365,"description":5290,"extension":5291,"links":5292,"meta":5293,"navigation":5295,"path":207,"seo":5296,"stem":208,"__hash__":5297},"docs\u002F3.sdks\u002F5.server\u002F7.ruby.md","Ruby Server SDK",{"type":366,"value":367,"toc":5255},"minimark",[368,372,378,382,386,395,399,407,415,444,470,474,495,498,750,761,765,770,791,808,815,820,849,855,861,939,949,957,974,1014,1043,1086,1092,1097,1106,1221,1300,1305,1308,1311,1328,1335,1368,1439,1443,1465,1540,1553,1663,1666,1926,1948,1967,1970,1979,1982,2043,2117,2194,2229,2250,2265,2293,2296,2299,2313,2317,2325,2329,2339,2346,2358,2362,2370,2387,2390,2404,2467,2470,2578,2591,2629,2633,2636,2639,2670,2673,2691,2821,2828,2832,2842,3074,3077,3118,3129,3143,3147,3150,3158,3164,3253,3258,3305,3311,3404,3413,3419,3503,3530,3535,3547,3551,3561,3669,3684,3700,3704,3713,3724,3883,3938,3956,3978,4033,4040,4044,4058,4062,4094,4159,4164,4173,4179,4182,4187,4205,4252,4281,4286,4295,4299,4311,4314,4320,4324,4335,4548,4567,4571,4577,4721,4731,4734,4762,4791,4795,4967,4972,5130,5134,5155,5159,5251],[369,370],"div",{"hidden":9,"dataTitleIcon":371},"ruby",[373,374],"external-badges",{"package-url":375,"registry":376,"repo":377},"https:\u002F\u002Frubygems.org\u002Fgems\u002Fconfigdirector-server-sdk","rubygems","ruby-sdks\u002Ftree\u002Fmain\u002Fconfigdirector-server-sdk",[379,380,5],"h2",{"id":381},"introduction",[383,384,385],"p",{},"The Ruby Server SDK is a server-side SDK that evaluates configs and their targeting rules. Upon initialization, it retrieves configs and targeting rules from ConfigDirector services. From that point on, it evaluates configs locally for any context, and receives updates via server sent events (SSE) when configs are updated on the dashboard or via the admin API.",[383,387,388,389,394],{},"The client is safe to share between threads. Each Ruby process holds its own client and its own connection to ConfigDirector: create the client the first time a process reads a config, share it for the lifetime of the process, and close it when the process exits. Evaluations read config state the client already holds in memory, so they make no network calls on the request path. Servers that fork their workers, such as Puma in cluster mode, are covered in ",[390,391,393],"a",{"href":392},"#servers-that-fork-their-workers","Servers that fork their workers",".",[379,396,398],{"id":397},"installation","Installation",[383,400,401,402],{},"The SDK can be installed with Bundler. Its gem page is on RubyGems: ",[390,403,375],{"href":375,"rel":404,"target":406},[405],"noopener","_blank",[383,408,409,410,414],{},"The minimum Ruby version supported is ",[411,412,413],"code",{},"3.3",", on CRuby, the standard Ruby interpreter.",[416,417,418],"code-group",{},[419,420,426],"pre",{"className":421,"code":422,"filename":423,"language":424,"meta":425,"style":425},"language-bash shiki shiki-themes github-light-high-contrast github-light github-dark","bundle add configdirector-server-sdk\n","bundler","bash","",[411,427,428],{"__ignoreMap":425},[429,430,433,437,441],"span",{"class":431,"line":432},"line",1,[429,434,436],{"class":435},"sA9AF","bundle",[429,438,440],{"class":439},"suztq"," add",[429,442,443],{"class":439}," configdirector-server-sdk\n",[383,445,446,447,450,451,454,455,458,459,462,463,466,467,394],{},"The SDK depends only on gems of Ruby's standard library: ",[411,448,449],{},"logger",", and ",[411,452,453],{},"net-http"," 0.10.0 or later, a newer release than Ruby ships. Your ",[411,456,457],{},"Gemfile.lock"," gains them, with ",[411,460,461],{},"net-protocol",", ",[411,464,465],{},"timeout"," and ",[411,468,469],{},"uri",[379,471,473],{"id":472},"configure-and-initialize-the-client","Configure and initialize the client",[475,476,477,485,492],"ol",{},[478,479,480,481,484],"li",{},"Create a client providing your server SDK key. You can retrieve a server SDK key for each environment under ",[411,482,483],{},"SDK keys"," in the dashboard's navigation panel. Creating the client makes no network call.",[478,486,487,488,491],{},"Call ",[411,489,490],{},"init"," to connect and wait for the first values.",[478,493,494],{},"Close the client when the process exits.",[383,496,497],{},"The example creates the client the first time a process reads a config, and returns that same client to every later read in the process:",[419,499,503],{"className":500,"code":501,"filename":502,"language":371,"meta":425,"style":425},"language-ruby shiki shiki-themes github-light-high-contrast github-light github-dark","require \"configdirector\"\n\n# Creates the client the first time a process reads a config, and returns that client afterwards.\nmodule ConfigDirectorClientPerProcess\n  @lock = Mutex.new\n  @client = nil\n\n  def self.client\n    @lock.synchronize { @client ||= created_and_initialized_client }\n  end\n\n  def self.created_and_initialized_client\n    # IMPORTANT: Do not commit the server SDK key to your source code, it is a secret value.\n    # Creating the client makes no network call.\n    client = ConfigDirector.create_client(ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"))\n\n    # Waits for the first values, up to the connection timeout. If none arrive in time, the client\n    # keeps connecting in the background and reads return their in-code default value until they do.\n    client.init\n\n    # Reports what the process evaluated since the last report, and closes the connection.\n    at_exit { client.close }\n    client\n  end\n\n  private_class_method :created_and_initialized_client\nend\n","lib\u002Fconfig_director_client_per_process.rb",[411,504,505,514,520,527,536,555,566,571,581,599,605,610,618,624,630,667,672,678,684,693,698,704,719,725,730,735,744],{"__ignoreMap":425},[429,506,507,511],{"class":431,"line":432},[429,508,510],{"class":509},"sLDKn","require",[429,512,513],{"class":439}," \"configdirector\"\n",[429,515,517],{"class":431,"line":516},2,[429,518,519],{"emptyLinePlaceholder":9},"\n",[429,521,523],{"class":431,"line":522},3,[429,524,526],{"class":525},"sM45V","# Creates the client the first time a process reads a config, and returns that client afterwards.\n",[429,528,530,533],{"class":431,"line":529},4,[429,531,532],{"class":509},"module",[429,534,535],{"class":435}," ConfigDirectorClientPerProcess\n",[429,537,539,543,546,550,552],{"class":431,"line":538},5,[429,540,542],{"class":541},"sbRM4","  @lock ",[429,544,545],{"class":509},"=",[429,547,549],{"class":548},"sxMNI"," Mutex",[429,551,394],{"class":541},[429,553,554],{"class":509},"new\n",[429,556,558,561,563],{"class":431,"line":557},6,[429,559,560],{"class":541},"  @client ",[429,562,545],{"class":509},[429,564,565],{"class":548}," nil\n",[429,567,569],{"class":431,"line":568},7,[429,570,519],{"emptyLinePlaceholder":9},[429,572,574,577],{"class":431,"line":573},8,[429,575,576],{"class":509},"  def",[429,578,580],{"class":579},"sEIia"," self.client\n",[429,582,584,587,590,593,596],{"class":431,"line":583},9,[429,585,586],{"class":541},"    @lock.",[429,588,589],{"class":579},"synchronize",[429,591,592],{"class":541}," { @client ",[429,594,595],{"class":509},"||=",[429,597,598],{"class":541}," created_and_initialized_client }\n",[429,600,602],{"class":431,"line":601},10,[429,603,604],{"class":509},"  end\n",[429,606,608],{"class":431,"line":607},11,[429,609,519],{"emptyLinePlaceholder":9},[429,611,613,615],{"class":431,"line":612},12,[429,614,576],{"class":509},[429,616,617],{"class":579}," self.created_and_initialized_client\n",[429,619,621],{"class":431,"line":620},13,[429,622,623],{"class":525},"    # IMPORTANT: Do not commit the server SDK key to your source code, it is a secret value.\n",[429,625,627],{"class":431,"line":626},14,[429,628,629],{"class":525},"    # Creating the client makes no network call.\n",[429,631,633,637,640,643,645,648,651,654,656,659,661,664],{"class":431,"line":632},15,[429,634,636],{"class":635},"syyZu","    client",[429,638,639],{"class":509}," =",[429,641,642],{"class":548}," ConfigDirector",[429,644,394],{"class":541},[429,646,647],{"class":579},"create_client",[429,649,650],{"class":541},"(",[429,652,653],{"class":548},"ENV",[429,655,394],{"class":541},[429,657,658],{"class":579},"fetch",[429,660,650],{"class":541},[429,662,663],{"class":439},"\"CONFIGDIRECTOR_SERVER_KEY\"",[429,665,666],{"class":541},"))\n",[429,668,670],{"class":431,"line":669},16,[429,671,519],{"emptyLinePlaceholder":9},[429,673,675],{"class":431,"line":674},17,[429,676,677],{"class":525},"    # Waits for the first values, up to the connection timeout. If none arrive in time, the client\n",[429,679,681],{"class":431,"line":680},18,[429,682,683],{"class":525},"    # keeps connecting in the background and reads return their in-code default value until they do.\n",[429,685,687,690],{"class":431,"line":686},19,[429,688,689],{"class":541},"    client.",[429,691,692],{"class":579},"init\n",[429,694,696],{"class":431,"line":695},20,[429,697,519],{"emptyLinePlaceholder":9},[429,699,701],{"class":431,"line":700},21,[429,702,703],{"class":525},"    # Reports what the process evaluated since the last report, and closes the connection.\n",[429,705,707,710,713,716],{"class":431,"line":706},22,[429,708,709],{"class":548},"    at_exit",[429,711,712],{"class":541}," { client.",[429,714,715],{"class":579},"close",[429,717,718],{"class":541}," }\n",[429,720,722],{"class":431,"line":721},23,[429,723,724],{"class":541},"    client\n",[429,726,728],{"class":431,"line":727},24,[429,729,604],{"class":509},[429,731,733],{"class":431,"line":732},25,[429,734,519],{"emptyLinePlaceholder":9},[429,736,738,741],{"class":431,"line":737},26,[429,739,740],{"class":509},"  private_class_method",[429,742,743],{"class":548}," :created_and_initialized_client\n",[429,745,747],{"class":431,"line":746},27,[429,748,749],{"class":509},"end\n",[383,751,752,753,756,757,760],{},"Read through ",[411,754,755],{},"ConfigDirectorClientPerProcess.client"," wherever your application reads a config. The client is safe to share between threads, and each process creates its own, as ",[390,758,393],{"href":759},"\u002Fsdks\u002Fserver\u002Fruby#servers-that-fork-their-workers"," explains.",[762,763,764],"warning",{},"Server SDK keys are secret values. Do not commit them to your source code repository. Provide them at runtime via environment variables instead.",[383,766,767,769],{},[411,768,490],{}," waits for the first values, up to the connection timeout, and the client is ready once they arrive. It never raises because the connection failed, and every read returns its in-code default value until values arrive:",[771,772,773,776,788],"ul",{},[478,774,775],{},"When no values arrive in time, it logs a warning and returns, and the client keeps connecting in the background.",[478,777,778,779,782,783,787],{},"When ConfigDirector refuses the connection, for example because it does not know the server SDK key, it logs an error, calls the ",[411,780,781],{},"connection_error"," ",[390,784,786],{"href":785},"#hooks","handlers"," and returns at once. The client does not try again.",[478,789,790],{},"In polling mode, when the first request for values fails for another reason, it logs an error and returns at once, and the client asks again after the polling interval.",[383,792,793,794,796,797,799,800,803,804,807],{},"Calling ",[411,795,490],{}," again waits again and never opens a second connection. On a closed client, ",[411,798,490],{}," raises ",[411,801,802],{},"ConfigDirector::ConfigDirectorValidationError",". ",[411,805,806],{},"ready?"," reports whether values have arrived.",[383,809,810,811,814],{},"The lock in the example matters on a threaded server such as Puma: without it, two first requests arriving together would each create and initialize a client. The ",[411,812,813],{},"at_exit"," handler closes the client when the process exits, which reports what the process evaluated since the last report; a process that exits without closing its client does not report its last reads.",[816,817,819],"h3",{"id":818},"additional-configuration-options","Additional configuration options",[383,821,822,825,826,830,831,834,835,838,839,842,843,845,846,848],{},[411,823,824],{},"ConfigDirector.create_client"," takes the server SDK key and the options below as keyword arguments. Only the key is required, and only outside ",[390,827,829],{"href":828},"#run-without-a-connection","offline mode",". An option object cannot be changed once built, and ",[411,832,833],{},"with"," builds a copy with other values. An option the client cannot use, such as a blank server SDK key, an unknown connection mode, or a URL that is not an ",[411,836,837],{},"http"," or ",[411,840,841],{},"https"," URL, raises ",[411,844,802],{}," from ",[411,847,647],{}," rather than returning a client that quietly never updates.",[850,851,853],"h4",{"id":852},"metadata",[411,854,852],{},[383,856,857,858,860],{},"The ",[411,859,852],{}," option allows you to provide your application's name and version. These values can be used in targeting rules conditionals. For example, if a certain feature should only be enabled starting with a certain version of your application.",[419,862,864],{"className":500,"code":863,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"),\n  metadata: ConfigDirector::Metadata.new(app_name: \"YOUR-APP-NAME\", app_version: \"1.0.2\")\n)\n",[411,865,866,882,898,935],{"__ignoreMap":425},[429,867,868,871,873,875,877,879],{"class":431,"line":432},[429,869,870],{"class":635},"client",[429,872,639],{"class":509},[429,874,642],{"class":548},[429,876,394],{"class":541},[429,878,647],{"class":579},[429,880,881],{"class":541},"(\n",[429,883,884,887,889,891,893,895],{"class":431,"line":516},[429,885,886],{"class":548},"  ENV",[429,888,394],{"class":541},[429,890,658],{"class":579},[429,892,650],{"class":541},[429,894,663],{"class":439},[429,896,897],{"class":541},"),\n",[429,899,900,903,905,908,911,913,916,918,921,924,926,929,932],{"class":431,"line":522},[429,901,902],{"class":548},"  metadata:",[429,904,642],{"class":548},[429,906,907],{"class":541},"::",[429,909,910],{"class":548},"Metadata",[429,912,394],{"class":541},[429,914,915],{"class":509},"new",[429,917,650],{"class":541},[429,919,920],{"class":548},"app_name:",[429,922,923],{"class":439}," \"YOUR-APP-NAME\"",[429,925,462],{"class":541},[429,927,928],{"class":548},"app_version:",[429,930,931],{"class":439}," \"1.0.2\"",[429,933,934],{"class":541},")\n",[429,936,937],{"class":431,"line":529},[429,938,934],{"class":541},[383,940,941,942,945,946,394],{},"A name or version that is not a String is read as its text, so ",[411,943,944],{},"app_version: 2"," is ",[411,947,948],{},"\"2\"",[850,950,952,466,954],{"id":951},"logger-and-log_level",[411,953,449],{},[411,955,956],{},"log_level",[383,958,959,960,962,963,966,967,838,970,973],{},"By default the SDK writes warnings and errors to standard error. The ",[411,961,956],{}," option sets the lowest level it writes there, as Ruby's ",[411,964,965],{},"Logger"," takes it, such as ",[411,968,969],{},":debug",[411,971,972],{},"Logger::INFO",":",[419,975,977],{"className":500,"code":976,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"), log_level: :debug)\n",[411,978,979],{"__ignoreMap":425},[429,980,981,983,985,987,989,991,993,995,997,999,1001,1003,1006,1009,1012],{"class":431,"line":432},[429,982,870],{"class":635},[429,984,639],{"class":509},[429,986,642],{"class":548},[429,988,394],{"class":541},[429,990,647],{"class":579},[429,992,650],{"class":541},[429,994,653],{"class":548},[429,996,394],{"class":541},[429,998,658],{"class":579},[429,1000,650],{"class":541},[429,1002,663],{"class":439},[429,1004,1005],{"class":541},"), ",[429,1007,1008],{"class":548},"log_level:",[429,1010,1011],{"class":548}," :debug",[429,1013,934],{"class":541},[383,1015,1016,1017,1019,1020,462,1023,462,1026,466,1029,1032,1033,1035,1036,1039,1040,1042],{},"To send the SDK's lines to your application's log, pass any object with the methods of Ruby's ",[411,1018,965],{}," (",[411,1021,1022],{},"debug",[411,1024,1025],{},"info",[411,1027,1028],{},"warn",[411,1030,1031],{},"error",") in the ",[411,1034,449],{}," option, such as ",[411,1037,1038],{},"Rails.logger",". The SDK calls each method with one String, and the logger's own level decides what is written, so ",[411,1041,956],{}," has no effect then:",[419,1044,1046],{"className":500,"code":1045,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"), logger: Rails.logger)\n",[411,1047,1048],{"__ignoreMap":425},[429,1049,1050,1052,1054,1056,1058,1060,1062,1064,1066,1068,1070,1072,1074,1077,1080,1082,1084],{"class":431,"line":432},[429,1051,870],{"class":635},[429,1053,639],{"class":509},[429,1055,642],{"class":548},[429,1057,394],{"class":541},[429,1059,647],{"class":579},[429,1061,650],{"class":541},[429,1063,653],{"class":548},[429,1065,394],{"class":541},[429,1067,658],{"class":579},[429,1069,650],{"class":541},[429,1071,663],{"class":439},[429,1073,1005],{"class":541},[429,1075,1076],{"class":548},"logger:",[429,1078,1079],{"class":548}," Rails",[429,1081,394],{"class":541},[429,1083,449],{"class":579},[429,1085,934],{"class":541},[383,1087,1088,1089,394],{},"At the debug level the SDK logs each config it evaluates, such as ",[411,1090,1091],{},"[ConfigDirectorClient] Evaluated \"new-checkout\" to true (found-match)",[850,1093,1095],{"id":1094},"connection",[411,1096,1094],{},[383,1098,857,1099,1101,1102,1105],{},[411,1100,1094],{}," option takes a ",[411,1103,1104],{},"ConfigDirector::ConnectionOptions"," with the following optional keyword arguments:",[771,1107,1108,1136,1158,1173,1190,1208],{},[478,1109,1110,1113],{},[411,1111,1112],{},"mode",[771,1114,1115,1131],{},[478,1116,1117,1118,462,1121,838,1124,1127,1128,394],{},"The connection mode, one of ",[411,1119,1120],{},"\"streaming\"",[411,1122,1123],{},"\"polling\"",[411,1125,1126],{},"\"offline\"",". It is recommended to use the default of streaming unless you have a specific need to use polling instead. In offline mode the client never connects to ConfigDirector and serves the values you give it; see ",[390,1129,1130],{"href":828},"Run without a connection",[478,1132,1133,1134],{},"Defaults to ",[411,1135,1120],{},[478,1137,1138,1141],{},[411,1139,1140],{},"file",[771,1142,1143],{},[478,1144,1145,1146,1149,1150,466,1152,1155,1156,394],{},"The path of a JSON file holding the values to serve in offline mode, as a String or a ",[411,1147,1148],{},"Pathname",", resolved against the working directory of the process. Only one of ",[411,1151,1140],{},[411,1153,1154],{},"values"," can be given, and only in offline mode. See ",[390,1157,1130],{"href":828},[478,1159,1160,1162],{},[411,1161,1154],{},[771,1163,1164],{},[478,1165,1166,1167,466,1169,1155,1171,394],{},"The values to serve in offline mode, as a Hash keyed by config key. Only one of ",[411,1168,1140],{},[411,1170,1154],{},[390,1172,1130],{"href":828},[478,1174,1175,1178],{},[411,1176,1177],{},"polling_interval",[771,1179,1180,1187],{},[478,1181,1182,1183,394],{},"Only used in polling mode. How often the client asks ConfigDirector services for updates, in seconds. A value below the minimum of 60 seconds is raised to 60 seconds and a warning is logged. See ",[390,1184,1186],{"href":1185},"\u002Fgetting-started\u002Farchitecture#polling-intervals","Polling intervals",[478,1188,1189],{},"Defaults to 300 seconds (5 minutes)",[478,1191,1192,1194],{},[411,1193,465],{},[771,1195,1196,1205],{},[478,1197,1198,1199,1201,1202,1204],{},"How long ",[411,1200,490],{}," waits for the first values, in seconds. If the timeout is reached, ",[411,1203,490],{}," returns but the client is still not ready and returns in-code default values. The client keeps trying to connect and retrieve config values in the background. In polling mode it is also how long each request for values may take. It has no effect in offline mode.",[478,1206,1207],{},"Defaults to 3 seconds",[478,1209,1210,1213],{},[411,1211,1212],{},"url",[771,1214,1215,1218],{},[478,1216,1217],{},"The base URL used to connect to ConfigDirector services",[478,1219,1220],{},"This should only be provided if your environment requires you to configure a proxy server in order to connect to ConfigDirector services. It has no effect in offline mode.",[419,1222,1224],{"className":500,"code":1223,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"),\n  connection: ConfigDirector::ConnectionOptions.new(mode: \"polling\", polling_interval: 600, timeout: 5)\n)\n",[411,1225,1226,1240,1254,1296],{"__ignoreMap":425},[429,1227,1228,1230,1232,1234,1236,1238],{"class":431,"line":432},[429,1229,870],{"class":635},[429,1231,639],{"class":509},[429,1233,642],{"class":548},[429,1235,394],{"class":541},[429,1237,647],{"class":579},[429,1239,881],{"class":541},[429,1241,1242,1244,1246,1248,1250,1252],{"class":431,"line":516},[429,1243,886],{"class":548},[429,1245,394],{"class":541},[429,1247,658],{"class":579},[429,1249,650],{"class":541},[429,1251,663],{"class":439},[429,1253,897],{"class":541},[429,1255,1256,1259,1261,1263,1266,1268,1270,1272,1275,1278,1280,1283,1286,1288,1291,1294],{"class":431,"line":522},[429,1257,1258],{"class":548},"  connection:",[429,1260,642],{"class":548},[429,1262,907],{"class":541},[429,1264,1265],{"class":548},"ConnectionOptions",[429,1267,394],{"class":541},[429,1269,915],{"class":509},[429,1271,650],{"class":541},[429,1273,1274],{"class":548},"mode:",[429,1276,1277],{"class":439}," \"polling\"",[429,1279,462],{"class":541},[429,1281,1282],{"class":548},"polling_interval:",[429,1284,1285],{"class":548}," 600",[429,1287,462],{"class":541},[429,1289,1290],{"class":548},"timeout:",[429,1292,1293],{"class":548}," 5",[429,1295,934],{"class":541},[429,1297,1298],{"class":431,"line":529},[429,1299,934],{"class":541},[850,1301,1303],{"id":1302},"telemetry",[411,1304,1302],{},[383,1306,1307],{},"Telemetry tuning. It is unlikely these settings need to be adjusted. However, in cases where your application has a large number of evaluations per second, you can adjust these settings to tune the memory footprint and frequency of telemetry requests.",[383,1309,1310],{},"Keep in mind that ConfigDirector relies on these telemetry events to provide insights and features related to the configs being used.",[383,1312,1313,1314,1318,1319,1321,1322,450,1325,1327],{},"Each evaluation the SDK reports says which variation was served and which percentage rollout and share served it. That is how ConfigDirector counts the contexts each variation of an experiment reached. ",[390,1315,1317],{"href":1316},"#track-events","Tracked events"," are sent with the same reports. The client sends its first report 5 seconds after ",[411,1320,490],{},", then one every ",[411,1323,1324],{},"flush_interval",[411,1326,715],{}," sends the last one.",[383,1329,857,1330,1101,1332,1105],{},[411,1331,1302],{},[411,1333,1334],{},"ConfigDirector::TelemetryOptions",[771,1336,1337,1353],{},[478,1338,1339,1342],{},[411,1340,1341],{},"event_queue_limit",[771,1343,1344,1347,1350],{},[478,1345,1346],{},"The size limit of telemetry event queues. If the size limit is reached before the events are flushed to the network, older events are dropped.",[478,1348,1349],{},"ConfigDirector keeps a count of dropped events. If the number of dropped events is higher than 50% of the total events, ConfigDirector issues an alert in the dashboard.",[478,1351,1352],{},"A number between 100 and 100,000. Defaults to 5,000.",[478,1354,1355,1357],{},[411,1356,1324],{},[771,1358,1359,1362,1365],{},[478,1360,1361],{},"How often events are flushed and sent over the network, in seconds.",[478,1363,1364],{},"Decrease this number if your application consistently captures a large number of events in short periods of time in order to reduce memory footprint from a large event queue.",[478,1366,1367],{},"Defaults to 30 seconds.",[419,1369,1371],{"className":500,"code":1370,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"),\n  telemetry: ConfigDirector::TelemetryOptions.new(event_queue_limit: 10_000, flush_interval: 15)\n)\n",[411,1372,1373,1387,1401,1435],{"__ignoreMap":425},[429,1374,1375,1377,1379,1381,1383,1385],{"class":431,"line":432},[429,1376,870],{"class":635},[429,1378,639],{"class":509},[429,1380,642],{"class":548},[429,1382,394],{"class":541},[429,1384,647],{"class":579},[429,1386,881],{"class":541},[429,1388,1389,1391,1393,1395,1397,1399],{"class":431,"line":516},[429,1390,886],{"class":548},[429,1392,394],{"class":541},[429,1394,658],{"class":579},[429,1396,650],{"class":541},[429,1398,663],{"class":439},[429,1400,897],{"class":541},[429,1402,1403,1406,1408,1410,1413,1415,1417,1419,1422,1425,1427,1430,1433],{"class":431,"line":522},[429,1404,1405],{"class":548},"  telemetry:",[429,1407,642],{"class":548},[429,1409,907],{"class":541},[429,1411,1412],{"class":548},"TelemetryOptions",[429,1414,394],{"class":541},[429,1416,915],{"class":509},[429,1418,650],{"class":541},[429,1420,1421],{"class":548},"event_queue_limit:",[429,1423,1424],{"class":548}," 10_000",[429,1426,462],{"class":541},[429,1428,1429],{"class":548},"flush_interval:",[429,1431,1432],{"class":548}," 15",[429,1434,934],{"class":541},[429,1436,1437],{"class":431,"line":529},[429,1438,934],{"class":541},[816,1440,1442],{"id":1441},"hooks","Hooks",[383,1444,1445,1446,1449,1450,1453,1454,1457,1458,1461,1462,1464],{},"Hooks are events you can subscribe to in order to be notified of some key actions from the client. Subscribe with ",[411,1447,1448],{},"on",", which takes the event name as a Symbol and a block, or any object that responds to ",[411,1451,1452],{},"call"," such as a lambda or ",[411,1455,1456],{},"method(:name)",", and returns a ",[411,1459,1460],{},"ConfigDirector::Subscription"," whose ",[411,1463,715],{}," removes the handler:",[419,1466,1469],{"className":500,"code":1467,"filename":1468,"language":371,"meta":425,"style":425},"subscription = client.on(:configs_updated) { |event| puts \"Updated: #{event.keys.join(\", \")}\" }\n\nsubscription.close\n","main.rb",[411,1470,1471,1528,1532],{"__ignoreMap":425},[429,1472,1473,1476,1478,1481,1483,1485,1488,1491,1494,1497,1501,1504,1507,1509,1512,1514,1517,1520,1523,1526],{"class":431,"line":432},[429,1474,1475],{"class":635},"subscription",[429,1477,639],{"class":509},[429,1479,1480],{"class":541}," client.",[429,1482,1448],{"class":579},[429,1484,650],{"class":541},[429,1486,1487],{"class":548},":configs_updated",[429,1489,1490],{"class":541},") { |event| ",[429,1492,1493],{"class":548},"puts",[429,1495,1496],{"class":439}," \"Updated: ",[429,1498,1500],{"class":1499},"spee4","#{",[429,1502,1503],{"class":439},"event.",[429,1505,1506],{"class":579},"keys",[429,1508,394],{"class":439},[429,1510,1511],{"class":579},"join",[429,1513,650],{"class":439},[429,1515,1516],{"class":439},"\", \"",[429,1518,1519],{"class":439},")",[429,1521,1522],{"class":1499},"}",[429,1524,1525],{"class":439},"\"",[429,1527,718],{"class":541},[429,1529,1530],{"class":431,"line":516},[429,1531,519],{"emptyLinePlaceholder":9},[429,1533,1534,1537],{"class":431,"line":522},[429,1535,1536],{"class":541},"subscription.",[429,1538,1539],{"class":579},"close\n",[383,1541,1542,1543,1545,1546,1549,1550,1552],{},"Or give the handlers in the ",[411,1544,1441],{}," option, a ",[411,1547,1548],{},"ConfigDirector::ClientHooks"," that takes one handler or an Array of handlers for each event. The client registers them before any handler registered with ",[411,1551,1448],{},", so they see the first values arrive:",[419,1554,1556],{"className":500,"code":1555,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  ENV.fetch(\"CONFIGDIRECTOR_SERVER_KEY\"),\n  hooks: ConfigDirector::ClientHooks.new(\n    config_evaluated: ->(event) { puts \"#{event.evaluation.key} evaluated to #{event.evaluation.value}\" }\n  )\n)\n",[411,1557,1558,1572,1586,1604,1654,1659],{"__ignoreMap":425},[429,1559,1560,1562,1564,1566,1568,1570],{"class":431,"line":432},[429,1561,870],{"class":635},[429,1563,639],{"class":509},[429,1565,642],{"class":548},[429,1567,394],{"class":541},[429,1569,647],{"class":579},[429,1571,881],{"class":541},[429,1573,1574,1576,1578,1580,1582,1584],{"class":431,"line":516},[429,1575,886],{"class":548},[429,1577,394],{"class":541},[429,1579,658],{"class":579},[429,1581,650],{"class":541},[429,1583,663],{"class":439},[429,1585,897],{"class":541},[429,1587,1588,1591,1593,1595,1598,1600,1602],{"class":431,"line":522},[429,1589,1590],{"class":548},"  hooks:",[429,1592,642],{"class":548},[429,1594,907],{"class":541},[429,1596,1597],{"class":548},"ClientHooks",[429,1599,394],{"class":541},[429,1601,915],{"class":509},[429,1603,881],{"class":541},[429,1605,1606,1609,1612,1615,1617,1620,1622,1624,1627,1629,1632,1634,1637,1639,1641,1643,1645,1648,1650,1652],{"class":431,"line":529},[429,1607,1608],{"class":548},"    config_evaluated:",[429,1610,1611],{"class":548}," ->",[429,1613,1614],{"class":541},"(event) { ",[429,1616,1493],{"class":548},[429,1618,1619],{"class":439}," \"",[429,1621,1500],{"class":1499},[429,1623,1503],{"class":439},[429,1625,1626],{"class":579},"evaluation",[429,1628,394],{"class":439},[429,1630,1631],{"class":579},"key",[429,1633,1522],{"class":1499},[429,1635,1636],{"class":439}," evaluated to ",[429,1638,1500],{"class":1499},[429,1640,1503],{"class":439},[429,1642,1626],{"class":579},[429,1644,394],{"class":439},[429,1646,1647],{"class":579},"value",[429,1649,1522],{"class":1499},[429,1651,1525],{"class":439},[429,1653,718],{"class":541},[429,1655,1656],{"class":431,"line":538},[429,1657,1658],{"class":541},"  )\n",[429,1660,1661],{"class":431,"line":557},[429,1662,934],{"class":541},[383,1664,1665],{},"The following hooks are available:",[771,1667,1668,1688,1713,1903],{},[478,1669,1670,1675],{},[411,1671,1674],{"className":1672},[1673],"font-semibold","client_ready",[771,1676,1677],{},[478,1678,1679,1680,1683,1684,1687],{},"Called with no argument when the client is initialized. When this event is emitted it means the client has received a payload from the ConfigDirector servers, or has loaded its ",[390,1681,1682],{"href":828},"offline values",", and is ready to evaluate configs. It is emitted once, after the ",[411,1685,1686],{},"configs_updated"," handlers and the watches.",[478,1689,1690,1694],{},[411,1691,1693],{"className":1692},[1673],"configs_updated: ConfigDirector::ConfigsUpdatedEvent",[771,1695,1696,1702,1707],{},[478,1697,1698,1699,1701],{},"Called when a payload is received from the ConfigDirector servers with config data. It is emitted during initialization when an entire config payload is received, or when the ",[390,1700,1682],{"href":828}," are loaded. After initialization, it is emitted when updates are pushed from the server (or discovered via polling if that connection mode is used).",[478,1703,1704,1706],{},[411,1705,1506],{}," - The config keys that were included in the payload from the server, in the order the server sent them, followed by the keys of configs whose targeting rules use a segment the payload included.",[478,1708,1709,1712],{},[411,1710,1711],{},"removed_keys"," - The keys of configs the payload removed. A config is removed when a full payload no longer includes it. Empty when nothing was removed.",[478,1714,1715,1719],{},[411,1716,1718],{"className":1717},[1673],"config_evaluated: ConfigDirector::ConfigEvaluatedEvent",[771,1720,1721,1731],{},[478,1722,1723,1724,466,1727,1730],{},"Called whenever a config is evaluated, before the read returns. This includes calls to ",[411,1725,1726],{},"get_value",[411,1728,1729],{},"evaluate",", and evaluations delivered to watches.",[478,1732,1733,1735,1736,1739,1740],{},[411,1734,1626],{}," - A ",[411,1737,1738],{},"ConfigDirector::ConfigEvaluation"," with the details of the evaluation:\n",[771,1741,1742,1747,1755,1779,1807,1813,1894],{},[478,1743,1744,1746],{},[411,1745,1631],{}," - The config key that was evaluated",[478,1748,1749,1751,1752,1754],{},[411,1750,1647],{}," - The value the config evaluated to, of the class of the in-code default value. It can be the in-code default value provided to ",[411,1753,1726],{}," or to the watch. For example, if the config was evaluated before the client was initialized.",[478,1756,1757,1760,1761,1763,1764,1767,1768,462,1770,462,1772,462,1774,466,1776,1778],{},[411,1758,1759],{},"value_id"," - The value ID, a stable hash of the value that you can send to a third party rather than the ",[411,1762,1647],{},". This can be useful for large values, like a JSON config, or to avoid disclosing the values themselves. It is ",[411,1765,1766],{},"nil"," when the evaluation fell back to the in-code default value. To report an experiment to an analytics tool, send the variation instead: the pages for ",[390,1769,311],{"href":312},[390,1771,327],{"href":328},[390,1773,319],{"href":320},[390,1775,335],{"href":336},[390,1777,331],{"href":332}," name the event each one reads.",[478,1780,1781,1784,1785,1788,1789,466,1792,1795,1796,1798,1799,945,1801,1803,1804,1806],{},[411,1782,1783],{},"variation"," - The variation that was served, a ",[411,1786,1787],{},"ConfigDirector::Variation"," with its ",[411,1790,1791],{},"id",[411,1793,1794],{},"name",". The ",[411,1797,1791],{}," stays the same when the variation is renamed, and ",[411,1800,1794],{},[411,1802,1766],{}," for a variation without one. It is ",[411,1805,1766],{}," when the config has no variations or the in-code default value is returned.",[478,1808,1809,1812],{},[411,1810,1811],{},"default_value?"," - Whether or not the evaluation fell back to the in-code default value.",[478,1814,1815,1818,1819,1822,1823,1825,1826,1829,1830,1832,1833,1839,1840,1842,1843],{},[411,1816,1817],{},"reason"," - The reason for the evaluation resolution, as a String. In the case the config successfully evaluated based on server-provided targeting rules, or served an offline value, it is ",[411,1820,1821],{},"found-match",". A context without an ",[411,1824,1791],{}," that is served the default targeting rule value after skipping a percentage rollout reports ",[411,1827,1828],{},"rollout-skipped-no-identifier",", with ",[411,1831,1811],{}," false; see ",[390,1834,1836,1837],{"href":1835},"#contexts-without-an-id","Contexts without an ",[411,1838,1791],{},". If the evaluation had to fall back to the in-code default value, the ",[411,1841,1817],{}," says why the fallback was required:\n",[771,1844,1845,1851,1857,1863,1876,1882,1888],{},[478,1846,1847,1850],{},[411,1848,1849],{},"client-not-ready"," - The evaluation happened before the client finished initialization, or after it was closed",[478,1852,1853,1856],{},[411,1854,1855],{},"config-state-missing"," - The requested config key was not present in the payload received from the server, usually because of an incorrect config key",[478,1858,1859,1862],{},[411,1860,1861],{},"invalid-number"," - The config was requested as a number but the value received from the server could not be read as that kind of number",[478,1864,1865,1868,1869,1872,1873],{},[411,1866,1867],{},"invalid-boolean"," - The config was requested as a boolean but the value received from the server was neither ",[411,1870,1871],{},"true"," nor ",[411,1874,1875],{},"false",[478,1877,1878,1881],{},[411,1879,1880],{},"invalid-json"," - The config was requested with a Hash in-code default value but the value received from the server is not a JSON object, or with an Array but it is not a JSON array",[478,1883,1884,1887],{},[411,1885,1886],{},"type-mismatch"," - The config was requested as a String but it is a boolean or number config",[478,1889,1890,1893],{},[411,1891,1892],{},"value-missing"," - The config key was present in the payload received from the server, but it carried no value",[478,1895,1896,1899,1900,1902],{},[411,1897,1898],{},"context"," - The context that was provided to the evaluation, or ",[411,1901,1766],{}," when none was given or it was ignored for an invalid context kind",[478,1904,1905,1909],{},[411,1906,1908],{"className":1907},[1673],"connection_error: ConfigDirector::ConnectionErrorEvent",[771,1910,1911,1914],{},[478,1912,1913],{},"Called when ConfigDirector refuses the connection, for example because it does not know the server SDK key, and the client will not try again. It is emitted at most once.",[478,1915,1916,1735,1918,1921,1922,1925],{},[411,1917,1031],{},[411,1919,1920],{},"ConfigDirector::ConfigDirectorConnectionError"," saying why, whose ",[411,1923,1924],{},"status"," is the HTTP status ConfigDirector answered with.",[383,1927,1928,462,1930,466,1932,1934,1935,1937,1938,803,1940,1943,1944,1947],{},[411,1929,1674],{},[411,1931,1686],{},[411,1933,781],{}," handlers run on the thread that received the values: in streaming mode a background thread of the SDK, so one that blocks delays later updates; in polling mode the thread that called ",[411,1936,490],{}," for the first request and a background thread for every later one; in offline mode the thread that called ",[411,1939,490],{},[411,1941,1942],{},"config_evaluated"," handlers run on the thread that read the value, or on the thread that delivered the update when a watch fires. A handler can read from the client. A ",[411,1945,1946],{},"StandardError"," raised in a handler is logged at error level and ignored; the other handlers and the connection continue.",[383,1949,1950,1951,1954,1955,450,1958,1961,1962,1964,1965,394],{},"A handler registered twice runs twice. ",[411,1952,1953],{},"off(:configs_updated, handler)"," removes the first registration of ",[411,1956,1957],{},"handler",[411,1959,1960],{},"off(:configs_updated)"," removes every handler of the event, hooks included. A block or a lambda is found only as the same object, while ",[411,1963,1456],{}," finds a handler registered as ",[411,1966,1456],{},[816,1968,1130],{"id":1969},"run-without-a-connection",[383,1971,1972,1973,1975,1976,1978],{},"Set the connection ",[411,1974,1112],{}," to ",[411,1977,1126],{}," to run your application without connecting to ConfigDirector, for example in a suite of UI tests where each run pins every flag to a known value. An offline client needs no server SDK key, opens no connection and sends nothing, so the application is invisible to the ConfigDirector dashboard: no evaluations are counted and no lifecycle state changes. Every context receives the same value and targeting rules are not applied.",[383,1980,1981],{},"Give the values in a JSON file, with one value per config key, or inline:",[419,1983,1985],{"className":500,"code":1984,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  connection: ConfigDirector::ConnectionOptions.new(mode: \"offline\", file: \"flags\u002Fnew-checkout-on.json\")\n)\nclient.init\n",[411,1986,1987,2001,2032,2036],{"__ignoreMap":425},[429,1988,1989,1991,1993,1995,1997,1999],{"class":431,"line":432},[429,1990,870],{"class":635},[429,1992,639],{"class":509},[429,1994,642],{"class":548},[429,1996,394],{"class":541},[429,1998,647],{"class":579},[429,2000,881],{"class":541},[429,2002,2003,2005,2007,2009,2011,2013,2015,2017,2019,2022,2024,2027,2030],{"class":431,"line":516},[429,2004,1258],{"class":548},[429,2006,642],{"class":548},[429,2008,907],{"class":541},[429,2010,1265],{"class":548},[429,2012,394],{"class":541},[429,2014,915],{"class":509},[429,2016,650],{"class":541},[429,2018,1274],{"class":548},[429,2020,2021],{"class":439}," \"offline\"",[429,2023,462],{"class":541},[429,2025,2026],{"class":548},"file:",[429,2028,2029],{"class":439}," \"flags\u002Fnew-checkout-on.json\"",[429,2031,934],{"class":541},[429,2033,2034],{"class":431,"line":522},[429,2035,934],{"class":541},[429,2037,2038,2041],{"class":431,"line":529},[429,2039,2040],{"class":541},"client.",[429,2042,692],{"class":579},[419,2044,2049],{"className":2045,"code":2046,"filename":2047,"language":2048,"meta":425,"style":425},"language-json shiki shiki-themes github-light-high-contrast github-light github-dark","{\n  \"new-checkout\": true,\n  \"max-items\": 20,\n  \"greeting\": \"hello\",\n  \"theme\": { \"color\": \"blue\" }\n}\n","flags\u002Fnew-checkout-on.json","json",[411,2050,2051,2056,2070,2082,2094,2112],{"__ignoreMap":425},[429,2052,2053],{"class":431,"line":432},[429,2054,2055],{"class":541},"{\n",[429,2057,2058,2062,2065,2067],{"class":431,"line":516},[429,2059,2061],{"class":2060},"sa4_4","  \"new-checkout\"",[429,2063,2064],{"class":541},": ",[429,2066,1871],{"class":548},[429,2068,2069],{"class":541},",\n",[429,2071,2072,2075,2077,2080],{"class":431,"line":522},[429,2073,2074],{"class":2060},"  \"max-items\"",[429,2076,2064],{"class":541},[429,2078,2079],{"class":548},"20",[429,2081,2069],{"class":541},[429,2083,2084,2087,2089,2092],{"class":431,"line":529},[429,2085,2086],{"class":2060},"  \"greeting\"",[429,2088,2064],{"class":541},[429,2090,2091],{"class":439},"\"hello\"",[429,2093,2069],{"class":541},[429,2095,2096,2099,2102,2105,2107,2110],{"class":431,"line":538},[429,2097,2098],{"class":2060},"  \"theme\"",[429,2100,2101],{"class":541},": { ",[429,2103,2104],{"class":2060},"\"color\"",[429,2106,2064],{"class":541},[429,2108,2109],{"class":439},"\"blue\"",[429,2111,718],{"class":541},[429,2113,2114],{"class":431,"line":557},[429,2115,2116],{"class":541},"}\n",[419,2118,2120],{"className":500,"code":2119,"filename":502,"language":371,"meta":425,"style":425},"client = ConfigDirector.create_client(\n  connection: ConfigDirector::ConnectionOptions.new(mode: \"offline\", values: { \"new-checkout\" => true, \"max-items\" => 20 })\n)\nclient.init\n",[411,2121,2122,2136,2184,2188],{"__ignoreMap":425},[429,2123,2124,2126,2128,2130,2132,2134],{"class":431,"line":432},[429,2125,870],{"class":635},[429,2127,639],{"class":509},[429,2129,642],{"class":548},[429,2131,394],{"class":541},[429,2133,647],{"class":579},[429,2135,881],{"class":541},[429,2137,2138,2140,2142,2144,2146,2148,2150,2152,2154,2156,2158,2161,2164,2167,2170,2172,2174,2177,2179,2181],{"class":431,"line":516},[429,2139,1258],{"class":548},[429,2141,642],{"class":548},[429,2143,907],{"class":541},[429,2145,1265],{"class":548},[429,2147,394],{"class":541},[429,2149,915],{"class":509},[429,2151,650],{"class":541},[429,2153,1274],{"class":548},[429,2155,2021],{"class":439},[429,2157,462],{"class":541},[429,2159,2160],{"class":548},"values:",[429,2162,2163],{"class":541}," { ",[429,2165,2166],{"class":439},"\"new-checkout\"",[429,2168,2169],{"class":541}," => ",[429,2171,1871],{"class":548},[429,2173,462],{"class":541},[429,2175,2176],{"class":439},"\"max-items\"",[429,2178,2169],{"class":541},[429,2180,2079],{"class":548},[429,2182,2183],{"class":541}," })\n",[429,2185,2186],{"class":431,"line":522},[429,2187,934],{"class":541},[429,2189,2190,2192],{"class":431,"line":529},[429,2191,2040],{"class":541},[429,2193,692],{"class":579},[383,2195,2196,2197,838,2199,1019,2201,2204,2205,2208,2209,2212,2213,2215,2216,2220,2221,838,2223,2225,2226,2228],{},"The file path is resolved against the working directory of the process. The config type of each value in the file follows from the value itself: ",[411,2198,1871],{},[411,2200,1875],{},[411,2202,2203],{},"boolean","), a whole number written without a decimal point or exponent (",[411,2206,2207],{},"integer","), any other number (",[411,2210,2211],{},"float","), a string, or an object or array (",[411,2214,2048],{},"). Inline values follow the same rule with Ruby classes, exactly as the ",[390,2217,2219],{"href":2218},"#values","test client"," reads them: ",[411,2222,1871],{},[411,2224,1875],{},", an Integer, a Float, a String, or a Hash or an Array, which can hold ",[411,2227,1766],{},". A key is a String or a Symbol, and a Symbol is read as its name. A value read with an in-code default value of another class returns the in-code default value, as it does against ConfigDirector.",[383,2230,2231,2233,2234,2236,2237,2239,2240,2242,2243,462,2245,466,2247,2249],{},[411,2232,490],{}," loads the values, and reads the file, each time it is called, and the client is ready when it returns. Each time, it calls the ",[411,2235,1686],{}," handlers with every key the values hold, and every watch, as it does when values arrive from ConfigDirector; ",[411,2238,1674],{}," is called the first time only. Offline values never change on their own, so a watch is called again only when ",[411,2241,490],{}," is. ",[411,2244,1177],{},[411,2246,465],{},[411,2248,1212],{}," have no effect.",[383,2251,2252,2253,2256,2257,1872,2259,2261,2262,2264],{},"With ",[411,2254,2255],{},"mode: \"offline\""," and neither ",[411,2258,1140],{},[411,2260,1154],{},", the client is ready once ",[411,2263,490],{}," returns and every config returns its in-code default value.",[383,2266,2267,799,2269,2271,2272,466,2274,2276,2277,2279,2280,799,2282,2285,2286,2289,2290,2292],{},[411,2268,647],{},[411,2270,802],{}," when ",[411,2273,1140],{},[411,2275,1154],{}," are both given, either is given in streaming or polling mode, or an inline value is ",[411,2278,1766],{},", a Symbol or of a class not listed above. ",[411,2281,490],{},[411,2283,2284],{},"ConfigDirector::ConfigDirectorInitializationError"," when the file is missing, cannot be read, is not a JSON object or holds a value such as ",[411,2287,2288],{},"null",". The client stays not ready, so a test run that starts from a misspelled path fails instead of passing on in-code default values. A later ",[411,2291,490],{}," that cannot load the file raises the same way and keeps serving the values loaded before.",[383,2294,2295],{},"If you come from LaunchDarkly, a file of values is what LaunchDarkly calls \"flags from files\", and offline mode with no values is its \"offline mode\".",[379,2297,393],{"id":2298},"servers-that-fork-their-workers",[383,2300,2301,2302,2305,2306,2309,2310,394],{},"Puma in cluster mode, Passenger's smart spawning and Unicorn with ",[411,2303,2304],{},"preload_app true"," load your application once and then fork their workers from that process. Since Puma 7, cluster mode loads the application before it forks by default. A Rails application as generated runs Puma in single mode, where nothing forks, until ",[411,2307,2308],{},"workers"," is set in ",[411,2311,2312],{},"config\u002Fpuma.rb",[816,2314,2316],{"id":2315},"one-connection-per-process","One connection per process",[383,2318,2319,2320,2324],{},"Each Ruby process that reads configs holds its own client and its own connection to ConfigDirector, so a server with four workers counts as four connections, and an application on 2 hosts with 4 workers each counts 8. Each connection counts toward your organization's ",[390,2321,2323],{"href":2322},"\u002Fgetting-started\u002Fpricing-and-billing#billing-metrics","service connection hours"," for as long as it is open.",[816,2326,2328],{"id":2327},"a-client-initialized-before-the-fork","A client initialized before the fork",[383,2330,2331,2332,2335,2336,2338],{},"A client that was initialized before the fork keeps working in each worker, with nothing for your application to call. At the fork, the worker serves at once the values the client held, then opens its own connection in the background and receives updates from then on. ",[411,2333,2334],{},"fork"," does not wait for that connection. The client's handlers and watches keep being called in the worker, and the worker reports what it evaluates. In streaming mode, the worker calls the ",[411,2337,1686],{}," handlers with every key, and every watch, once shortly after the fork, even when nothing changed. The connection of the process that forked is not touched, and closing the client in a worker closes that worker's connection only.",[383,2340,2341,2342,2345],{},"A client that was never initialized, was closed, runs in offline mode, or whose server SDK key ConfigDirector refused does nothing at the fork. A process that ",[411,2343,2344],{},"Process.daemon"," starts keeps working the same way.",[383,2347,2348,2349,2351,2352,2354,2355,2357],{},"If a handler or a watch that runs in the background calls ",[411,2350,2334],{}," without a block, the forked process ends when the handler returns, with exit status 0 and after its ",[411,2353,813],{}," handlers, as it would at the end of a ",[411,2356,2334],{}," block.",[816,2359,2361],{"id":2360},"create-the-client-the-first-time-it-is-used","Create the client the first time it is used",[383,2363,2364,2365,2369],{},"Even though a client initialized at boot keeps working after the fork, create it the first time a process reads a config, as the ",[390,2366,2368],{"href":2367},"#configure-and-initialize-the-client","setup code"," does, rather than while the application boots. A client created and initialized at boot, in a Rails initializer for example, also connects in every other process that loads the application:",[771,2371,2372,2375,2381],{},[478,2373,2374],{},"the Puma master, which serves no request, so a host with four workers holds five connections;",[478,2376,2377,2380],{},[411,2378,2379],{},"bin\u002Frails console"," and every Rake task, for as long as they run;",[478,2382,2383,2386],{},[411,2384,2385],{},"assets:precompile"," in an image build that has no server SDK key, where creating the client raises.",[383,2388,2389],{},"Created on first use, a client exists only in a process that reads a config, so only such a process connects. The first request in each worker waits for the first values, up to the connection timeout.",[383,2391,2392,2393,2395,2396,2399,2400,2403],{},"In a Rails application, put the setup code in ",[411,2394,502],{}," and load ",[411,2397,2398],{},"lib\u002F"," with ",[411,2401,2402],{},"autoload_lib_once",", so that Rails does not reload the module when code changes in development. A reloaded module would forget its client and create a second one.",[419,2405,2408],{"className":500,"code":2406,"filename":2407,"language":371,"meta":425,"style":425},"module MyApp\n  class Application \u003C Rails::Application\n    config.load_defaults 8.1\n    config.autoload_lib_once(ignore: %w[assets tasks])\n  end\nend\n","config\u002Fapplication.rb",[411,2409,2410,2417,2432,2443,2459,2463],{"__ignoreMap":425},[429,2411,2412,2414],{"class":431,"line":432},[429,2413,532],{"class":509},[429,2415,2416],{"class":435}," MyApp\n",[429,2418,2419,2422,2425,2428],{"class":431,"line":516},[429,2420,2421],{"class":509},"  class",[429,2423,2424],{"class":435}," Application",[429,2426,2427],{"class":541}," \u003C ",[429,2429,2431],{"class":2430},"sT_Me","Rails::Application\n",[429,2433,2434,2437,2440],{"class":431,"line":522},[429,2435,2436],{"class":541},"    config.",[429,2438,2439],{"class":579},"load_defaults",[429,2441,2442],{"class":548}," 8.1\n",[429,2444,2445,2447,2449,2451,2454,2457],{"class":431,"line":529},[429,2446,2436],{"class":541},[429,2448,2402],{"class":579},[429,2450,650],{"class":541},[429,2452,2453],{"class":548},"ignore:",[429,2455,2456],{"class":439}," %w[assets tasks]",[429,2458,934],{"class":541},[429,2460,2461],{"class":431,"line":538},[429,2462,604],{"class":509},[429,2464,2465],{"class":431,"line":557},[429,2466,749],{"class":509},[383,2468,2469],{},"Read through the module wherever a config is read:",[419,2471,2474],{"className":500,"code":2472,"filename":2473,"language":371,"meta":425,"style":425},"class CheckoutController \u003C ApplicationController\n  def show\n    client = ConfigDirectorClientPerProcess.client\n    context = ConfigDirector::Context.new(id: params[:user_id])\n    render json: { \"new-checkout\" => client.get_value(\"new-checkout\", false, context) }\n  end\nend\n","app\u002Fcontrollers\u002Fcheckout_controller.rb",[411,2475,2476,2489,2496,2510,2542,2570,2574],{"__ignoreMap":425},[429,2477,2478,2481,2484,2486],{"class":431,"line":432},[429,2479,2480],{"class":509},"class",[429,2482,2483],{"class":435}," CheckoutController",[429,2485,2427],{"class":541},[429,2487,2488],{"class":2430},"ApplicationController\n",[429,2490,2491,2493],{"class":431,"line":516},[429,2492,576],{"class":509},[429,2494,2495],{"class":579}," show\n",[429,2497,2498,2500,2502,2505,2507],{"class":431,"line":522},[429,2499,636],{"class":635},[429,2501,639],{"class":509},[429,2503,2504],{"class":548}," ConfigDirectorClientPerProcess",[429,2506,394],{"class":541},[429,2508,2509],{"class":579},"client\n",[429,2511,2512,2515,2517,2519,2521,2524,2526,2528,2530,2533,2536,2539],{"class":431,"line":529},[429,2513,2514],{"class":635},"    context",[429,2516,639],{"class":509},[429,2518,642],{"class":548},[429,2520,907],{"class":541},[429,2522,2523],{"class":548},"Context",[429,2525,394],{"class":541},[429,2527,915],{"class":509},[429,2529,650],{"class":541},[429,2531,2532],{"class":548},"id:",[429,2534,2535],{"class":541}," params[",[429,2537,2538],{"class":548},":user_id",[429,2540,2541],{"class":541},"])\n",[429,2543,2544,2547,2550,2552,2554,2557,2559,2561,2563,2565,2567],{"class":431,"line":538},[429,2545,2546],{"class":541},"    render ",[429,2548,2549],{"class":548},"json:",[429,2551,2163],{"class":541},[429,2553,2166],{"class":439},[429,2555,2556],{"class":541}," => client.",[429,2558,1726],{"class":579},[429,2560,650],{"class":541},[429,2562,2166],{"class":439},[429,2564,462],{"class":541},[429,2566,1875],{"class":548},[429,2568,2569],{"class":541},", context) }\n",[429,2571,2572],{"class":431,"line":557},[429,2573,604],{"class":509},[429,2575,2576],{"class":431,"line":568},[429,2577,749],{"class":509},[383,2579,2252,2580,2583,2584,2586,2587,2590],{},[411,2581,2582],{},"workers 4"," in ",[411,2585,2312],{},", each of the four workers creates its own client on its first request, and the master creates none. To have each worker wait for its first values before it serves a request instead, call the same method from Puma's ",[411,2588,2589],{},"before_worker_boot"," hook, which runs in each worker after the fork:",[419,2592,2594],{"className":500,"code":2593,"filename":2312,"language":371,"meta":425,"style":425},"workers 4\n\nbefore_worker_boot do\n  ConfigDirectorClientPerProcess.client\nend\n",[411,2595,2596,2604,2608,2616,2625],{"__ignoreMap":425},[429,2597,2598,2601],{"class":431,"line":432},[429,2599,2600],{"class":541},"workers ",[429,2602,2603],{"class":548},"4\n",[429,2605,2606],{"class":431,"line":516},[429,2607,519],{"emptyLinePlaceholder":9},[429,2609,2610,2613],{"class":431,"line":522},[429,2611,2612],{"class":541},"before_worker_boot ",[429,2614,2615],{"class":509},"do\n",[429,2617,2618,2621,2623],{"class":431,"line":529},[429,2619,2620],{"class":548},"  ConfigDirectorClientPerProcess",[429,2622,394],{"class":541},[429,2624,2509],{"class":579},[429,2626,2627],{"class":431,"line":538},[429,2628,749],{"class":509},[816,2630,2632],{"id":2631},"applications-that-fork-for-each-job","Applications that fork for each job",[383,2634,2635],{},"Resque, by default, forks a new process for each job. Most other job servers, such as Sidekiq, run many jobs in one long-lived process, which needs nothing beyond the setup above.",[383,2637,2638],{},"Initialize the client in the Resque worker before it forks, so that each job starts with the values the worker had at the fork:",[419,2640,2643],{"className":500,"code":2641,"filename":2642,"language":371,"meta":425,"style":425},"Resque.before_first_fork do\n  ConfigDirectorClientPerProcess.client\nend\n","config\u002Finitializers\u002Fresque.rb",[411,2644,2645,2658,2666],{"__ignoreMap":425},[429,2646,2647,2650,2652,2655],{"class":431,"line":432},[429,2648,2649],{"class":548},"Resque",[429,2651,394],{"class":541},[429,2653,2654],{"class":579},"before_first_fork",[429,2656,2657],{"class":509}," do\n",[429,2659,2660,2662,2664],{"class":431,"line":516},[429,2661,2620],{"class":548},[429,2663,394],{"class":541},[429,2665,2509],{"class":579},[429,2667,2668],{"class":431,"line":522},[429,2669,749],{"class":509},[383,2671,2672],{},"A job that reads its configs and ends within a few milliseconds then opens no connection. A job that runs longer opens its own connection and downloads every value, so a worker that runs 10 such jobs a second opens 10 connections a second.",[383,2674,2675,2676,2679,2680,2682,2683,2686,2687,2690],{},"A job reports what it evaluated only when it closes the client or runs for 5 seconds. Resque ends each job's process with ",[411,2677,2678],{},"exit!",", which skips the ",[411,2681,813],{}," handler of the setup code, so close the client in the job's ",[411,2684,2685],{},"after_perform"," hook, and in its ",[411,2688,2689],{},"on_failure"," hook, which Resque calls instead when the job raises:",[419,2692,2695],{"className":500,"code":2693,"filename":2694,"language":371,"meta":425,"style":425},"class SendInvoice\n  @queue = :invoices\n\n  def self.perform(invoice_id)\n    client = ConfigDirectorClientPerProcess.client\n    # ...\n  end\n\n  def self.after_perform_close_the_configdirector_client(*)\n    ConfigDirectorClientPerProcess.client.close\n  end\n\n  def self.on_failure_close_the_configdirector_client(*)\n    ConfigDirectorClientPerProcess.client.close\n  end\nend\n","app\u002Fjobs\u002Fsend_invoice.rb",[411,2696,2697,2704,2714,2718,2728,2740,2745,2749,2753,2767,2780,2784,2788,2801,2813,2817],{"__ignoreMap":425},[429,2698,2699,2701],{"class":431,"line":432},[429,2700,2480],{"class":509},[429,2702,2703],{"class":435}," SendInvoice\n",[429,2705,2706,2709,2711],{"class":431,"line":516},[429,2707,2708],{"class":541},"  @queue ",[429,2710,545],{"class":509},[429,2712,2713],{"class":548}," :invoices\n",[429,2715,2716],{"class":431,"line":522},[429,2717,519],{"emptyLinePlaceholder":9},[429,2719,2720,2722,2725],{"class":431,"line":529},[429,2721,576],{"class":509},[429,2723,2724],{"class":579}," self.perform",[429,2726,2727],{"class":541},"(invoice_id)\n",[429,2729,2730,2732,2734,2736,2738],{"class":431,"line":538},[429,2731,636],{"class":635},[429,2733,639],{"class":509},[429,2735,2504],{"class":548},[429,2737,394],{"class":541},[429,2739,2509],{"class":579},[429,2741,2742],{"class":431,"line":557},[429,2743,2744],{"class":525},"    # ...\n",[429,2746,2747],{"class":431,"line":568},[429,2748,604],{"class":509},[429,2750,2751],{"class":431,"line":573},[429,2752,519],{"emptyLinePlaceholder":9},[429,2754,2755,2757,2760,2762,2765],{"class":431,"line":583},[429,2756,576],{"class":509},[429,2758,2759],{"class":579}," self.after_perform_close_the_configdirector_client",[429,2761,650],{"class":541},[429,2763,2764],{"class":509},"*",[429,2766,934],{"class":541},[429,2768,2769,2772,2774,2776,2778],{"class":431,"line":601},[429,2770,2771],{"class":548},"    ConfigDirectorClientPerProcess",[429,2773,394],{"class":541},[429,2775,870],{"class":579},[429,2777,394],{"class":541},[429,2779,1539],{"class":579},[429,2781,2782],{"class":431,"line":607},[429,2783,604],{"class":509},[429,2785,2786],{"class":431,"line":612},[429,2787,519],{"emptyLinePlaceholder":9},[429,2789,2790,2792,2795,2797,2799],{"class":431,"line":620},[429,2791,576],{"class":509},[429,2793,2794],{"class":579}," self.on_failure_close_the_configdirector_client",[429,2796,650],{"class":541},[429,2798,2764],{"class":509},[429,2800,934],{"class":541},[429,2802,2803,2805,2807,2809,2811],{"class":431,"line":626},[429,2804,2771],{"class":548},[429,2806,394],{"class":541},[429,2808,870],{"class":579},[429,2810,394],{"class":541},[429,2812,1539],{"class":579},[429,2814,2815],{"class":431,"line":632},[429,2816,604],{"class":509},[429,2818,2819],{"class":431,"line":669},[429,2820,749],{"class":509},[383,2822,2823,2824,2827],{},"Closing sends the job's report before its process ends, so each job waits for one request to ConfigDirector, up to 5 seconds. With ",[411,2825,2826],{},"FORK_PER_JOB=false",", Resque runs every job in the worker's own process, which must not close its client: leave the hooks out then.",[379,2829,2831],{"id":2830},"retrieve-config-values","Retrieve config values",[383,2833,2834,2835,2837,2838,2841],{},"Retrieve config values with ",[411,2836,1726],{},", and subscribe to updates with ",[411,2839,2840],{},"watch",". The first argument is the config key, the second is the in-code default value, which is returned if the config is not available or cannot be read as its class, and the third is the context targeting rules are evaluated for. The class of the in-code default value decides how the config is read:",[419,2843,2845],{"className":500,"code":2844,"filename":1468,"language":371,"meta":425,"style":425},"client = ConfigDirectorClientPerProcess.client\nuser = ConfigDirector::Context.new(id: \"user-id\")\n\n# Retrieve config values\nretries = client.get_value(\"max-retries\", 3, user)\ntheme = client.get_value(\"theme\", \"light\", user)\nnew_checkout = client.get_value(\"new-checkout\", false, user)\n\n# A JSON config is read as a Hash, and so is its in-code default value\nlimits = client.get_value(\"rate-limits\", { \"per_minute\" => 60 }, user)\n\n# Watch for config updates\nsubscription = client.watch(\"new-checkout\", false, user) do |enabled|\n  puts \"new-checkout is now #{enabled}\"\nend\n\n# Close the subscription when the watch is no longer needed\nsubscription.close\n",[411,2846,2847,2859,2885,2889,2894,2918,2941,2962,2966,2971,3001,3005,3010,3037,3055,3059,3063,3068],{"__ignoreMap":425},[429,2848,2849,2851,2853,2855,2857],{"class":431,"line":432},[429,2850,870],{"class":635},[429,2852,639],{"class":509},[429,2854,2504],{"class":548},[429,2856,394],{"class":541},[429,2858,2509],{"class":579},[429,2860,2861,2864,2866,2868,2870,2872,2874,2876,2878,2880,2883],{"class":431,"line":516},[429,2862,2863],{"class":635},"user",[429,2865,639],{"class":509},[429,2867,642],{"class":548},[429,2869,907],{"class":541},[429,2871,2523],{"class":548},[429,2873,394],{"class":541},[429,2875,915],{"class":509},[429,2877,650],{"class":541},[429,2879,2532],{"class":548},[429,2881,2882],{"class":439}," \"user-id\"",[429,2884,934],{"class":541},[429,2886,2887],{"class":431,"line":522},[429,2888,519],{"emptyLinePlaceholder":9},[429,2890,2891],{"class":431,"line":529},[429,2892,2893],{"class":525},"# Retrieve config values\n",[429,2895,2896,2899,2901,2903,2905,2907,2910,2912,2915],{"class":431,"line":538},[429,2897,2898],{"class":635},"retries",[429,2900,639],{"class":509},[429,2902,1480],{"class":541},[429,2904,1726],{"class":579},[429,2906,650],{"class":541},[429,2908,2909],{"class":439},"\"max-retries\"",[429,2911,462],{"class":541},[429,2913,2914],{"class":548},"3",[429,2916,2917],{"class":541},", user)\n",[429,2919,2920,2923,2925,2927,2929,2931,2934,2936,2939],{"class":431,"line":557},[429,2921,2922],{"class":635},"theme",[429,2924,639],{"class":509},[429,2926,1480],{"class":541},[429,2928,1726],{"class":579},[429,2930,650],{"class":541},[429,2932,2933],{"class":439},"\"theme\"",[429,2935,462],{"class":541},[429,2937,2938],{"class":439},"\"light\"",[429,2940,2917],{"class":541},[429,2942,2943,2946,2948,2950,2952,2954,2956,2958,2960],{"class":431,"line":568},[429,2944,2945],{"class":635},"new_checkout",[429,2947,639],{"class":509},[429,2949,1480],{"class":541},[429,2951,1726],{"class":579},[429,2953,650],{"class":541},[429,2955,2166],{"class":439},[429,2957,462],{"class":541},[429,2959,1875],{"class":548},[429,2961,2917],{"class":541},[429,2963,2964],{"class":431,"line":573},[429,2965,519],{"emptyLinePlaceholder":9},[429,2967,2968],{"class":431,"line":583},[429,2969,2970],{"class":525},"# A JSON config is read as a Hash, and so is its in-code default value\n",[429,2972,2973,2976,2978,2980,2982,2984,2987,2990,2993,2995,2998],{"class":431,"line":601},[429,2974,2975],{"class":635},"limits",[429,2977,639],{"class":509},[429,2979,1480],{"class":541},[429,2981,1726],{"class":579},[429,2983,650],{"class":541},[429,2985,2986],{"class":439},"\"rate-limits\"",[429,2988,2989],{"class":541},", { ",[429,2991,2992],{"class":439},"\"per_minute\"",[429,2994,2169],{"class":541},[429,2996,2997],{"class":548},"60",[429,2999,3000],{"class":541}," }, user)\n",[429,3002,3003],{"class":431,"line":607},[429,3004,519],{"emptyLinePlaceholder":9},[429,3006,3007],{"class":431,"line":612},[429,3008,3009],{"class":525},"# Watch for config updates\n",[429,3011,3012,3014,3016,3018,3020,3022,3024,3026,3028,3031,3034],{"class":431,"line":620},[429,3013,1475],{"class":635},[429,3015,639],{"class":509},[429,3017,1480],{"class":541},[429,3019,2840],{"class":579},[429,3021,650],{"class":541},[429,3023,2166],{"class":439},[429,3025,462],{"class":541},[429,3027,1875],{"class":548},[429,3029,3030],{"class":541},", user) ",[429,3032,3033],{"class":509},"do",[429,3035,3036],{"class":541}," |enabled|\n",[429,3038,3039,3042,3045,3047,3050,3052],{"class":431,"line":626},[429,3040,3041],{"class":548},"  puts",[429,3043,3044],{"class":439}," \"new-checkout is now ",[429,3046,1500],{"class":1499},[429,3048,3049],{"class":439},"enabled",[429,3051,1522],{"class":1499},[429,3053,3054],{"class":439},"\"\n",[429,3056,3057],{"class":431,"line":632},[429,3058,749],{"class":509},[429,3060,3061],{"class":431,"line":669},[429,3062,519],{"emptyLinePlaceholder":9},[429,3064,3065],{"class":431,"line":674},[429,3066,3067],{"class":525},"# Close the subscription when the watch is no longer needed\n",[429,3069,3070,3072],{"class":431,"line":680},[429,3071,1536],{"class":541},[429,3073,1539],{"class":579},[383,3075,3076],{},"The class of the in-code default value decides how a config is read, not how the config was declared in the dashboard, so the in-code default value should always be the safe choice:",[771,3078,3079,3095,3098,3112,3115],{},[478,3080,3081,838,3083,3085,3086,466,3088,3090,3091,3094],{},[411,3082,1871],{},[411,3084,1875],{}," reads a boolean. Only ",[411,3087,1871],{},[411,3089,1875],{}," read as a boolean, in any letter case. A config holding ",[411,3092,3093],{},"1"," yields the in-code default value.",[478,3096,3097],{},"A String reads the text of any config that is not a boolean, integer or float config, as the server spelled it, with no parsing, so a JSON config gives its JSON. A boolean or number config read with a String gives the in-code default value instead.",[478,3099,3100,3101,838,3104,3107,3108,3111],{},"An Integer reads a whole number. A whole number the server wrote as ",[411,3102,3103],{},"26.0",[411,3105,3106],{},"2.6e1"," still reads as ",[411,3109,3110],{},"26",". Any other number yields the in-code default value.",[478,3113,3114],{},"A Float reads any finite number.",[478,3116,3117],{},"A Hash reads a JSON object and an Array reads a JSON array, with String keys. The in-code default value is returned as it is, never merged with the config's members.",[383,3119,3120,3122,3123,3125,3126,394],{},[411,3121,1766],{},", a Symbol or any other class of in-code default value raises ",[411,3124,802],{},", and so does a context that is not a ",[411,3127,3128],{},"ConfigDirector::Context",[3130,3131,3132,3134,3135,3140,3141,394],"note",{},[411,3133,1726],{}," never raises when a config is missing or its value will not read as the class of the in-code default value; it returns your in-code default value instead. Which of those happened is reported by ",[390,3136,3138],{"href":3137},"#evaluate",[411,3139,1729],{}," and through ",[411,3142,1942],{},[816,3144,3146],{"id":3145},"evaluate-config-values-with-a-context","Evaluate config values with a context",[3130,3148,3149],{},"Unlike client SDKs, the server SDKs are able to evaluate targeting rules for the given context locally without additional network calls.",[383,3151,3152,3154,3155,3157],{},[411,3153,1726],{}," takes a ",[411,3156,3128],{}," as its third argument, which is what targeting rules are evaluated against. The same key can therefore resolve differently per user. Leave it out when there is no user to evaluate for.",[383,3159,3160,3161,3163],{},"The context is the last argument of ",[411,3162,1726],{},". Unlike client SDKs, the server SDKs are able to evaluate targeting rules for the given context locally without additional network calls.",[419,3165,3167],{"className":500,"code":3166,"filename":1468,"language":371,"meta":425,"style":425},"user = ConfigDirector::Context.new(\n  id: \"12345\",\n  name: \"Example User\",\n  traits: { \"region\" => \"North America\" } # Any arbitrary traits which can be referenced in targeting rules\n)\n\nclient.get_value(\"my-boolean-config-key\", false, user)\n",[411,3168,3169,3187,3197,3207,3228,3232,3236],{"__ignoreMap":425},[429,3170,3171,3173,3175,3177,3179,3181,3183,3185],{"class":431,"line":432},[429,3172,2863],{"class":635},[429,3174,639],{"class":509},[429,3176,642],{"class":548},[429,3178,907],{"class":541},[429,3180,2523],{"class":548},[429,3182,394],{"class":541},[429,3184,915],{"class":509},[429,3186,881],{"class":541},[429,3188,3189,3192,3195],{"class":431,"line":516},[429,3190,3191],{"class":548},"  id:",[429,3193,3194],{"class":439}," \"12345\"",[429,3196,2069],{"class":541},[429,3198,3199,3202,3205],{"class":431,"line":522},[429,3200,3201],{"class":548},"  name:",[429,3203,3204],{"class":439}," \"Example User\"",[429,3206,2069],{"class":541},[429,3208,3209,3212,3214,3217,3219,3222,3225],{"class":431,"line":529},[429,3210,3211],{"class":548},"  traits:",[429,3213,2163],{"class":541},[429,3215,3216],{"class":439},"\"region\"",[429,3218,2169],{"class":541},[429,3220,3221],{"class":439},"\"North America\"",[429,3223,3224],{"class":541}," } ",[429,3226,3227],{"class":525},"# Any arbitrary traits which can be referenced in targeting rules\n",[429,3229,3230],{"class":431,"line":538},[429,3231,934],{"class":541},[429,3233,3234],{"class":431,"line":557},[429,3235,519],{"emptyLinePlaceholder":9},[429,3237,3238,3240,3242,3244,3247,3249,3251],{"class":431,"line":568},[429,3239,2040],{"class":541},[429,3241,1726],{"class":579},[429,3243,650],{"class":541},[429,3245,3246],{"class":439},"\"my-boolean-config-key\"",[429,3248,462],{"class":541},[429,3250,1875],{"class":548},[429,3252,2917],{"class":541},[383,3254,3255,3256,973],{},"It is also the third argument of ",[411,3257,2840],{},[419,3259,3261],{"className":500,"code":3260,"filename":1468,"language":371,"meta":425,"style":425},"subscription = client.watch(\"new-checkout\", false, user) do |enabled|\n  puts \"new-checkout is now #{enabled}\"\nend\n",[411,3262,3263,3287,3301],{"__ignoreMap":425},[429,3264,3265,3267,3269,3271,3273,3275,3277,3279,3281,3283,3285],{"class":431,"line":432},[429,3266,1475],{"class":635},[429,3268,639],{"class":509},[429,3270,1480],{"class":541},[429,3272,2840],{"class":579},[429,3274,650],{"class":541},[429,3276,2166],{"class":439},[429,3278,462],{"class":541},[429,3280,1875],{"class":548},[429,3282,3030],{"class":541},[429,3284,3033],{"class":509},[429,3286,3036],{"class":541},[429,3288,3289,3291,3293,3295,3297,3299],{"class":431,"line":516},[429,3290,3041],{"class":548},[429,3292,3044],{"class":439},[429,3294,1500],{"class":1499},[429,3296,3049],{"class":439},[429,3298,1522],{"class":1499},[429,3300,3054],{"class":439},[429,3302,3303],{"class":431,"line":522},[429,3304,749],{"class":509},[383,3306,3307,3308,973],{},"To evaluate configs for an entity other than a user, such as a tenant, set the context kind with ",[411,3309,3310],{},"kind",[419,3312,3314],{"className":500,"code":3313,"filename":1468,"language":371,"meta":425,"style":425},"tenant = ConfigDirector::Context.new(\n  id: \"acme\",\n  kind: \"tenant\",\n  name: \"Acme Inc.\",\n  traits: { \"plan\" => \"enterprise\" }\n)\n\nclient.get_value(\"my-boolean-config-key\", false, tenant)\n",[411,3315,3316,3335,3344,3354,3363,3379,3383,3387],{"__ignoreMap":425},[429,3317,3318,3321,3323,3325,3327,3329,3331,3333],{"class":431,"line":432},[429,3319,3320],{"class":635},"tenant",[429,3322,639],{"class":509},[429,3324,642],{"class":548},[429,3326,907],{"class":541},[429,3328,2523],{"class":548},[429,3330,394],{"class":541},[429,3332,915],{"class":509},[429,3334,881],{"class":541},[429,3336,3337,3339,3342],{"class":431,"line":516},[429,3338,3191],{"class":548},[429,3340,3341],{"class":439}," \"acme\"",[429,3343,2069],{"class":541},[429,3345,3346,3349,3352],{"class":431,"line":522},[429,3347,3348],{"class":548},"  kind:",[429,3350,3351],{"class":439}," \"tenant\"",[429,3353,2069],{"class":541},[429,3355,3356,3358,3361],{"class":431,"line":529},[429,3357,3201],{"class":548},[429,3359,3360],{"class":439}," \"Acme Inc.\"",[429,3362,2069],{"class":541},[429,3364,3365,3367,3369,3372,3374,3377],{"class":431,"line":538},[429,3366,3211],{"class":548},[429,3368,2163],{"class":541},[429,3370,3371],{"class":439},"\"plan\"",[429,3373,2169],{"class":541},[429,3375,3376],{"class":439},"\"enterprise\"",[429,3378,718],{"class":541},[429,3380,3381],{"class":431,"line":557},[429,3382,934],{"class":541},[429,3384,3385],{"class":431,"line":568},[429,3386,519],{"emptyLinePlaceholder":9},[429,3388,3389,3391,3393,3395,3397,3399,3401],{"class":431,"line":573},[429,3390,2040],{"class":541},[429,3392,1726],{"class":579},[429,3394,650],{"class":541},[429,3396,3246],{"class":439},[429,3398,462],{"class":541},[429,3400,1875],{"class":548},[429,3402,3403],{"class":541},", tenant)\n",[383,3405,3406,3407,3409,3410,3412],{},"Leaving ",[411,3408,3310],{}," out means ",[411,3411,2863],{},". A context kind is 1 to 64 lowercase letters, digits, dashes, or underscores. A context with an invalid context kind is ignored: the SDK logs an error, and configs are evaluated as if no context had been given.",[383,3414,3415,3418],{},[411,3416,3417],{},"ConfigDirector::Context.new"," takes the following keyword arguments, all optional:",[771,3420,3421,3434,3447,3456,3488],{},[478,3422,3423,3425],{},[411,3424,1791],{},[771,3426,3427],{},[478,3428,3429,3430,394],{},"The context's identifier, a String, or an Integer such as the ID of a database record, which is read as its digits. With the context kind, it decides the context's bucket in a percentage rollout, so changing it can move the context into a different bucket. A context without one skips percentage rollouts; see ",[390,3431,1836,3432],{"href":1835},[411,3433,1791],{},[478,3435,3436,3438],{},[411,3437,3310],{},[771,3439,3440],{},[478,3441,3442,3443,3446],{},"The context kind, such as ",[411,3444,3445],{},"\"tenant\"",". Contexts of different kinds are separate contexts even when they share an identifier, and a percentage rollout can place them in different shares.",[478,3448,3449,3451],{},[411,3450,1794],{},[771,3452,3453],{},[478,3454,3455],{},"The context's display name, a String.",[478,3457,3458,3461],{},[411,3459,3460],{},"traits",[771,3462,3463],{},[478,3464,3465,3466,462,3468,462,3470,3472,3473,3476,3477,3479,3480,3483,3484,3487],{},"A Hash of arbitrary traits which can be referenced in targeting rules, keyed by the name the rule references. A trait is a String, a number, ",[411,3467,1871],{},[411,3469,1875],{},[411,3471,1766],{},", or an Array or Hash of them. A Symbol key or value is read as its text, so ",[411,3474,3475],{},"{ plan: :pro }"," is the trait ",[411,3478,3371],{}," with the value ",[411,3481,3482],{},"\"pro\"",". Give a date as ISO 8601 text, such as ",[411,3485,3486],{},"user.created_at.iso8601",", so date conditions can compare it.",[478,3489,3490,3493],{},[411,3491,3492],{},"anonymous",[771,3494,3495],{},[478,3496,3497,3499,3500,394],{},[411,3498,1871],{}," keeps the context out of the dashboard: it is evaluated but never persisted, and telemetry reports neither the context nor its ID. Read it with ",[411,3501,3502],{},"anonymous?",[383,3504,3505,799,3508,2271,3510,3512,3513,3515,3516,3518,3519,3521,3522,1872,3524,3526,3527,3529],{},[411,3506,3507],{},"Context.new",[411,3509,802],{},[411,3511,1791],{}," is neither a String nor an Integer, ",[411,3514,1794],{}," is not a String, ",[411,3517,3460],{}," is not a Hash or is nested deeper than 100 levels, or ",[411,3520,3492],{}," is neither ",[411,3523,1871],{},[411,3525,1875],{},". It never fails because of the kind. A context cannot be changed once built, two contexts built with the same values are equal, and ",[411,3528,833],{}," builds a copy with other values.",[850,3531,1836,3533],{"id":3532},"contexts-without-an-id",[411,3534,1791],{},[383,3536,3537,3538,3540,3541,3543,3544,3546],{},"A percentage rollout places each context in a share by its ",[411,3539,1791],{},", so a context without an ",[411,3542,1791],{}," skips percentage rollouts: a rollout does not apply to it, and the targeting rules after the rollout are tried, as they are after a conditional rule the context does not match. The default targeting rule value is served when none of them applies. A rule that serves a single value still applies to it. To keep an anonymous visitor in a rollout, give the context a stable ",[411,3545,1791],{},", such as a session ID.",[816,3548,3550],{"id":3549},"watch-for-updates","Watch for updates",[383,3552,3553,3555,3556,1461,3558,3560],{},[411,3554,2840],{}," takes the config key, the in-code default value, which also decides how each update is read, and an optional context, and calls its block with the newly evaluated value. It returns a ",[411,3557,1460],{},[411,3559,715],{}," removes the watch:",[419,3562,3564],{"className":500,"code":3563,"filename":1468,"language":371,"meta":425,"style":425},"subscription = client.watch(\n  \"new-checkout\",\n  false,\n  ConfigDirector::Context.new(id: \"user-id\", name: \"Example User\", traits: { \"region\" => \"North America\" })\n) do |enabled|\n  puts \"new-checkout is now #{enabled}\"\nend\n\nsubscription.close\n",[411,3565,3566,3578,3584,3591,3632,3641,3655,3659,3663],{"__ignoreMap":425},[429,3567,3568,3570,3572,3574,3576],{"class":431,"line":432},[429,3569,1475],{"class":635},[429,3571,639],{"class":509},[429,3573,1480],{"class":541},[429,3575,2840],{"class":579},[429,3577,881],{"class":541},[429,3579,3580,3582],{"class":431,"line":516},[429,3581,2061],{"class":439},[429,3583,2069],{"class":541},[429,3585,3586,3589],{"class":431,"line":522},[429,3587,3588],{"class":548},"  false",[429,3590,2069],{"class":541},[429,3592,3593,3596,3598,3600,3602,3604,3606,3608,3610,3612,3615,3617,3619,3622,3624,3626,3628,3630],{"class":431,"line":529},[429,3594,3595],{"class":548},"  ConfigDirector",[429,3597,907],{"class":541},[429,3599,2523],{"class":548},[429,3601,394],{"class":541},[429,3603,915],{"class":509},[429,3605,650],{"class":541},[429,3607,2532],{"class":548},[429,3609,2882],{"class":439},[429,3611,462],{"class":541},[429,3613,3614],{"class":548},"name:",[429,3616,3204],{"class":439},[429,3618,462],{"class":541},[429,3620,3621],{"class":548},"traits:",[429,3623,2163],{"class":541},[429,3625,3216],{"class":439},[429,3627,2169],{"class":541},[429,3629,3221],{"class":439},[429,3631,2183],{"class":541},[429,3633,3634,3637,3639],{"class":431,"line":538},[429,3635,3636],{"class":541},") ",[429,3638,3033],{"class":509},[429,3640,3036],{"class":541},[429,3642,3643,3645,3647,3649,3651,3653],{"class":431,"line":557},[429,3644,3041],{"class":548},[429,3646,3044],{"class":439},[429,3648,1500],{"class":1499},[429,3650,3049],{"class":439},[429,3652,1522],{"class":1499},[429,3654,3054],{"class":439},[429,3656,3657],{"class":431,"line":568},[429,3658,749],{"class":509},[429,3660,3661],{"class":431,"line":573},[429,3662,519],{"emptyLinePlaceholder":9},[429,3664,3665,3667],{"class":431,"line":583},[429,3666,1536],{"class":541},[429,3668,1539],{"class":579},[383,3670,3671,3672,3674,3675,3677,3678,3680,3681,3683],{},"A watch fires whenever an update carries its key or a segment the config's targeting rules use, whether or not the value changed. It is not called when it is registered, so a watch registered before ",[411,3673,490],{}," is called for the first values, and one registered afterwards only sees later updates. When a full payload no longer includes the watched config, the block is called with the in-code default value, so it always agrees with what ",[411,3676,1726],{}," would return. Blocks run on the thread that received the update, after the ",[411,3679,1686],{}," handlers, so one that blocks delays later updates. A ",[411,3682,1946],{}," a block raises is logged and ignored.",[383,3685,3686,3689,3690,3692,3693,450,3696,3699],{},[411,3687,3688],{},"unwatch(\"new-checkout\", on_change)"," removes the first watch on the key whose block is the same Proc, such as one given to ",[411,3691,2840],{}," as ",[411,3694,3695],{},"&on_change",[411,3697,3698],{},"unwatch(\"new-checkout\")"," removes every watch on the key.",[379,3701,3703],{"id":3702},"track-events","Track events",[383,3705,3706,3709,3710,394],{},[411,3707,3708],{},"track"," reports to ConfigDirector that something happened in your application, such as a completed checkout. ConfigDirector shows tracked events on the Live feed and counts them for each variation of a running experiment; see ",[390,3711,1317],{"href":3712},"\u002Fmonitoring\u002Factivity#tracked-events",[383,3714,3715,3717,3718,466,3720,3723],{},[411,3716,3708],{}," takes the name of the event and an optional context the event happened for. The event's ",[411,3719,1647],{},[411,3721,3722],{},"details"," are optional keyword arguments:",[419,3725,3727],{"className":500,"code":3726,"filename":1468,"language":371,"meta":425,"style":425},"client.track(\n  \"checkout-completed\",\n  ConfigDirector::Context.new(id: \"user-id\"),\n  value: 49.9,\n  details: { plan: \"pro\", seats: 3, tags: %w[beta internal], address: { city: \"Lisbon\" } }\n)\n\nclient.track(\"export-finished\", ConfigDirector::Context.new(id: \"acme\", kind: \"tenant\"))\n\nclient.track(\"nightly-sync-finished\")\n",[411,3728,3729,3737,3744,3764,3774,3819,3823,3827,3866,3870],{"__ignoreMap":425},[429,3730,3731,3733,3735],{"class":431,"line":432},[429,3732,2040],{"class":541},[429,3734,3708],{"class":579},[429,3736,881],{"class":541},[429,3738,3739,3742],{"class":431,"line":516},[429,3740,3741],{"class":439},"  \"checkout-completed\"",[429,3743,2069],{"class":541},[429,3745,3746,3748,3750,3752,3754,3756,3758,3760,3762],{"class":431,"line":522},[429,3747,3595],{"class":548},[429,3749,907],{"class":541},[429,3751,2523],{"class":548},[429,3753,394],{"class":541},[429,3755,915],{"class":509},[429,3757,650],{"class":541},[429,3759,2532],{"class":548},[429,3761,2882],{"class":439},[429,3763,897],{"class":541},[429,3765,3766,3769,3772],{"class":431,"line":529},[429,3767,3768],{"class":548},"  value:",[429,3770,3771],{"class":548}," 49.9",[429,3773,2069],{"class":541},[429,3775,3776,3779,3781,3784,3787,3789,3792,3795,3797,3800,3803,3805,3808,3810,3813,3816],{"class":431,"line":538},[429,3777,3778],{"class":548},"  details:",[429,3780,2163],{"class":541},[429,3782,3783],{"class":548},"plan:",[429,3785,3786],{"class":439}," \"pro\"",[429,3788,462],{"class":541},[429,3790,3791],{"class":548},"seats:",[429,3793,3794],{"class":548}," 3",[429,3796,462],{"class":541},[429,3798,3799],{"class":548},"tags:",[429,3801,3802],{"class":439}," %w[beta internal]",[429,3804,462],{"class":541},[429,3806,3807],{"class":548},"address:",[429,3809,2163],{"class":541},[429,3811,3812],{"class":548},"city:",[429,3814,3815],{"class":439}," \"Lisbon\"",[429,3817,3818],{"class":541}," } }\n",[429,3820,3821],{"class":431,"line":557},[429,3822,934],{"class":541},[429,3824,3825],{"class":431,"line":568},[429,3826,519],{"emptyLinePlaceholder":9},[429,3828,3829,3831,3833,3835,3838,3840,3843,3845,3847,3849,3851,3853,3855,3857,3859,3862,3864],{"class":431,"line":573},[429,3830,2040],{"class":541},[429,3832,3708],{"class":579},[429,3834,650],{"class":541},[429,3836,3837],{"class":439},"\"export-finished\"",[429,3839,462],{"class":541},[429,3841,3842],{"class":548},"ConfigDirector",[429,3844,907],{"class":541},[429,3846,2523],{"class":548},[429,3848,394],{"class":541},[429,3850,915],{"class":509},[429,3852,650],{"class":541},[429,3854,2532],{"class":548},[429,3856,3341],{"class":439},[429,3858,462],{"class":541},[429,3860,3861],{"class":548},"kind:",[429,3863,3351],{"class":439},[429,3865,666],{"class":541},[429,3867,3868],{"class":431,"line":583},[429,3869,519],{"emptyLinePlaceholder":9},[429,3871,3872,3874,3876,3878,3881],{"class":431,"line":601},[429,3873,2040],{"class":541},[429,3875,3708],{"class":579},[429,3877,650],{"class":541},[429,3879,3880],{"class":439},"\"nightly-sync-finished\"",[429,3882,934],{"class":541},[771,3884,3885,3888,3904],{},[478,3886,3887],{},"The name is a String, or a Symbol, which is read as its name.",[478,3889,3890,3892,3893,3896,3897,3900,3901,394],{},[411,3891,1647],{}," is a number the event measures, such as an amount of money, a count or a duration: an Integer or a finite Float. Any other number, such as a ",[411,3894,3895],{},"BigDecimal"," or a ",[411,3898,3899],{},"Rational",", is left out, so convert it with ",[411,3902,3903],{},"to_f",[478,3905,3906,3908,3909,462,3911,462,3913,3915,3916,3919,3920,3923,3924,3927,3928,3931,3932,3935,3936,394],{},[411,3907,3722],{}," is a Hash describing the event, with String or Symbol keys. Its values are Strings, numbers, ",[411,3910,1871],{},[411,3912,1875],{},[411,3914,1766],{},", Symbols, which are sent as their names, Times, or nested Hashes and Arrays of them. A ",[411,3917,3918],{},"Time",", Rails' ",[411,3921,3922],{},"ActiveSupport::TimeWithZone"," included, is sent as ISO 8601 text in UTC, such as ",[411,3925,3926],{},"2026-11-15T10:30:00.000Z",". A ",[411,3929,3930],{},"Date",", a ",[411,3933,3934],{},"DateTime"," or a value of any other class leaves the details out, and a Float that is not finite is sent as ",[411,3937,2288],{},[383,3939,3940,3941,3943,3944,3946,3947,3949,3950,3952,3953,3955],{},"An event counts for an experiment only when it is tracked for a context with an ",[411,3942,1791],{},", the same one the experiment's config was evaluated for, so pass the context you evaluate with when you track the outcome of an experiment. Without a context, or for a context without an ",[411,3945,1791],{},", the event is still reported and counts for no experiment. For a context marked ",[411,3948,3492],{},", the event is reported without the ",[411,3951,1791],{},", so it counts for no experiment either. A context with an invalid context kind is ignored as it is in an evaluation: the SDK logs an error and reports the event without a context. A context that is not a ",[411,3954,3128],{}," drops the event, with a warning.",[383,3957,3958,3960,3961,3963,3964,3969,3970,3972,3973,462,3975,3977],{},[411,3959,3708],{}," returns ",[411,3962,1766],{}," and never raises. The event is sent with the SDK's next telemetry report, every 30 seconds unless you changed ",[390,3965,3967],{"href":3966},"#telemetry",[411,3968,1324],{},". In ",[390,3971,829],{"href":828}," and after ",[411,3974,715],{},[411,3976,3708],{}," does nothing. The SDK applies these limits, and logs one warning for each of them per telemetry report:",[3979,3980,3981,3994],"table",{},[3982,3983,3984],"thead",{},[3985,3986,3987,3991],"tr",{},[3988,3989,3990],"th",{},"Limit",[3988,3992,3993],{},"Beyond it",[3995,3996,3997,4006,4014,4022],"tbody",{},[3985,3998,3999,4003],{},[4000,4001,4002],"td",{},"An event name of 1 to 150 characters",[4000,4004,4005],{},"The event is not reported.",[3985,4007,4008,4011],{},[4000,4009,4010],{},"1,000 tracked events in one telemetry report",[4000,4012,4013],{},"Further events are not reported until that report is sent.",[3985,4015,4016,4019],{},[4000,4017,4018],{},"Details of up to 20 top-level keys and 1 KB as JSON, nested up to 100 levels, holding only the values above",[4000,4020,4021],{},"The details are left out and the event is still reported.",[3985,4023,4024,4030],{},[4000,4025,4026,4027,4029],{},"A ",[411,4028,1647],{}," that is an Integer or a finite Float",[4000,4031,4032],{},"The value is left out and the event is still reported.",[383,4034,4035,4036,394],{},"ConfigDirector applies limits of its own to the events it stores; see ",[390,4037,4039],{"href":4038},"\u002Fmonitoring\u002Factivity#limits","Limits",[379,4041,4043],{"id":4042},"other-useful-client-features","Other useful client features",[383,4045,4046,4047,4049,4050,4053,4054,4057],{},"The client provides additional methods. Reads and ",[411,4048,715],{}," cannot be called from a signal handler, such as a block given to ",[411,4051,4052],{},"Signal.trap",": Ruby raises ",[411,4055,4056],{},"ThreadError"," there.",[816,4059,4060],{"id":1729},[411,4061,1729],{},[383,4063,4064,4065,4067,4068,4070,4071,4073,4074,4073,4076,4078,4079,4081,4082,4087,4088,4090,4091,4093],{},"Evaluates a config the way ",[411,4066,1726],{}," does, with the same three arguments, and returns the ",[411,4069,1738],{}," behind it — the value, whether it is the in-code default value, the ",[411,4072,1817],{},", the ",[411,4075,1759],{},[411,4077,1783],{},", and the ",[411,4080,1898],{}," — instead of the value alone. It is the same object the ",[390,4083,4084,4086],{"href":785},[411,4085,1942],{}," hook"," reports, so use it where the reason matters at the point of the read, such as when reporting an evaluation to another system; ",[411,4089,1726],{}," is enough everywhere else. Like every read, it reaches ",[411,4092,1942],{}," and is counted in telemetry.",[419,4095,4097],{"className":500,"code":4096,"filename":1468,"language":371,"meta":425,"style":425},"evaluation = client.evaluate(\"my-config-key\", false, ConfigDirector::Context.new(id: \"user-id\"))\nputs \"No config with this key reached the SDK.\" if evaluation.reason == \"config-state-missing\"\n",[411,4098,4099,4138],{"__ignoreMap":425},[429,4100,4101,4103,4105,4107,4109,4111,4114,4116,4118,4120,4122,4124,4126,4128,4130,4132,4134,4136],{"class":431,"line":432},[429,4102,1626],{"class":635},[429,4104,639],{"class":509},[429,4106,1480],{"class":541},[429,4108,1729],{"class":579},[429,4110,650],{"class":541},[429,4112,4113],{"class":439},"\"my-config-key\"",[429,4115,462],{"class":541},[429,4117,1875],{"class":548},[429,4119,462],{"class":541},[429,4121,3842],{"class":548},[429,4123,907],{"class":541},[429,4125,2523],{"class":548},[429,4127,394],{"class":541},[429,4129,915],{"class":509},[429,4131,650],{"class":541},[429,4133,2532],{"class":548},[429,4135,2882],{"class":439},[429,4137,666],{"class":541},[429,4139,4140,4142,4145,4148,4151,4153,4156],{"class":431,"line":516},[429,4141,1493],{"class":548},[429,4143,4144],{"class":439}," \"No config with this key reached the SDK.\"",[429,4146,4147],{"class":509}," if",[429,4149,4150],{"class":541}," evaluation.",[429,4152,1817],{"class":579},[429,4154,4155],{"class":509}," ==",[429,4157,4158],{"class":439}," \"config-state-missing\"\n",[816,4160,4162],{"id":4161},"ready",[411,4163,806],{},[383,4165,4166,4167,4169,4170,4172],{},"Returns whether the client has received config state and is ready to evaluate configs. It is initially ",[411,4168,1875],{}," and becomes ",[411,4171,1871],{}," once the first config state arrives. Until it does, every read returns its in-code default value.",[816,4174,4176],{"id":4175},"closed",[411,4177,4178],{},"closed?",[383,4180,4181],{},"Returns whether the client has been closed. A closed client cannot be reopened.",[816,4183,4185],{"id":4184},"get_all_configs",[411,4186,4184],{},[383,4188,4189,4190,4193,4194,4197,4198,4201,4202,4204],{},"Returns what every config serves to a context, as a Hash of config keys to ",[411,4191,4192],{},"ConfigDirector::ConfigState",", for example to hand the values to a page you render on the server. It takes two optional keyword arguments: ",[411,4195,4196],{},"context:",", the context to evaluate for, and ",[411,4199,4200],{},"config_keys:",", to get only those keys. It returns an empty Hash until the client is ready, and these reads reach no ",[411,4203,1942],{}," handler and are not counted in telemetry.",[419,4206,4208],{"className":500,"code":4207,"filename":1468,"language":371,"meta":425,"style":425},"configs = client.get_all_configs(context: ConfigDirector::Context.new(id: \"user-id\"), config_keys: [\"new-checkout\"])\n",[411,4209,4210],{"__ignoreMap":425},[429,4211,4212,4215,4217,4219,4221,4223,4225,4227,4229,4231,4233,4235,4237,4239,4241,4243,4245,4248,4250],{"class":431,"line":432},[429,4213,4214],{"class":635},"configs",[429,4216,639],{"class":509},[429,4218,1480],{"class":541},[429,4220,4184],{"class":579},[429,4222,650],{"class":541},[429,4224,4196],{"class":548},[429,4226,642],{"class":548},[429,4228,907],{"class":541},[429,4230,2523],{"class":548},[429,4232,394],{"class":541},[429,4234,915],{"class":509},[429,4236,650],{"class":541},[429,4238,2532],{"class":548},[429,4240,2882],{"class":439},[429,4242,1005],{"class":541},[429,4244,4200],{"class":548},[429,4246,4247],{"class":541}," [",[429,4249,2166],{"class":439},[429,4251,2541],{"class":541},[383,4253,4254,4255,4258,4259,462,4261,466,4263,4073,4266,4268,4269,4271,4272,4274,4275,466,4278,394],{},"Each ",[411,4256,4257],{},"ConfigState"," carries the config's ",[411,4260,1791],{},[411,4262,1631],{},[411,4264,4265],{},"type",[411,4267,1647],{}," served as text, its ",[411,4270,1759],{}," and its ",[411,4273,1783],{},". When a percentage rollout served the value, it also carries the rollout's ",[411,4276,4277],{},"rule_id",[411,4279,4280],{},"share_id",[816,4282,4284],{"id":4283},"unwatch_all",[411,4285,4283],{},[383,4287,4288,4289,4291,4292,4294],{},"Removes every watch on every config. Handlers registered with ",[411,4290,1448],{}," and the ",[411,4293,1441],{}," option stay.",[816,4296,4297],{"id":715},[411,4298,715],{},[383,4300,4301,4302,4304,4305,4307,4308,4310],{},"Closes the connection to ConfigDirector services, reports what the client evaluated and tracked since its last report, and removes every handler, hook and watch. It waits up to 5 seconds for ConfigDirector to answer the report, and up to 5 more when a report was already being sent. After ",[411,4303,715],{}," the client is not ready, every read returns its in-code default value and ",[411,4306,4184],{}," returns an empty Hash. Calling ",[411,4309,715],{}," more than once is harmless.",[383,4312,4313],{},"Only close when the process exits and will no longer make use of the client.",[762,4315,4316,4317,4319],{},"Never create a client inside a request. Each one waits in ",[411,4318,490],{}," for its first values, opens its own connection to ConfigDirector, and keeps it open until it is closed.",[379,4321,4323],{"id":4322},"test-your-code","Test your code",[383,4325,4326,4327,4330,4331,4334],{},"Use the SDK's testing entry point, ",[411,4328,4329],{},"configdirector\u002Ftesting",", to test the code that reads your configs and flags. It creates a ",[4332,4333,2219],"strong",{},": the SDK's real client over an in-memory connection that your test controls. Only the connection to ConfigDirector and the telemetry are replaced. Everything else is the same code that runs in production, so the code under test behaves exactly as it does against ConfigDirector, and no network connection is opened, no telemetry is sent, and no thread is started. It ships in the gem, so there is nothing else to install.",[419,4336,4339],{"className":500,"code":4337,"filename":4338,"language":371,"meta":425,"style":425},"require \"configdirector\u002Ftesting\"\n\nRSpec.describe CheckoutService do\n  it \"shows the new checkout while the flag is on\" do\n    test_client = ConfigDirector::Testing.create_test_client({ \"new-checkout\" => true, \"max-items\" => 20 })\n    service = CheckoutService.new(test_client.client)\n    test_client.client.init\n\n    expect(service.new_checkout_enabled?(\"user-123\")).to be(true)\n\n    test_client.set_value(\"new-checkout\", false)\n    expect(service.new_checkout_enabled?(\"user-123\")).to be(false)\n\n    test_client.client.close\n  end\nend\n","spec\u002Fcheckout_service_spec.rb",[411,4340,4341,4348,4352,4367,4377,4415,4435,4446,4450,4481,4485,4502,4526,4530,4540,4544],{"__ignoreMap":425},[429,4342,4343,4345],{"class":431,"line":432},[429,4344,510],{"class":509},[429,4346,4347],{"class":439}," \"configdirector\u002Ftesting\"\n",[429,4349,4350],{"class":431,"line":516},[429,4351,519],{"emptyLinePlaceholder":9},[429,4353,4354,4357,4359,4362,4365],{"class":431,"line":522},[429,4355,4356],{"class":548},"RSpec",[429,4358,394],{"class":541},[429,4360,4361],{"class":579},"describe",[429,4363,4364],{"class":548}," CheckoutService",[429,4366,2657],{"class":509},[429,4368,4369,4372,4375],{"class":431,"line":529},[429,4370,4371],{"class":541},"  it ",[429,4373,4374],{"class":439},"\"shows the new checkout while the flag is on\"",[429,4376,2657],{"class":509},[429,4378,4379,4382,4384,4386,4388,4391,4393,4396,4399,4401,4403,4405,4407,4409,4411,4413],{"class":431,"line":538},[429,4380,4381],{"class":635},"    test_client",[429,4383,639],{"class":509},[429,4385,642],{"class":548},[429,4387,907],{"class":541},[429,4389,4390],{"class":548},"Testing",[429,4392,394],{"class":541},[429,4394,4395],{"class":579},"create_test_client",[429,4397,4398],{"class":541},"({ ",[429,4400,2166],{"class":439},[429,4402,2169],{"class":541},[429,4404,1871],{"class":548},[429,4406,462],{"class":541},[429,4408,2176],{"class":439},[429,4410,2169],{"class":541},[429,4412,2079],{"class":548},[429,4414,2183],{"class":541},[429,4416,4417,4420,4422,4424,4426,4428,4431,4433],{"class":431,"line":557},[429,4418,4419],{"class":635},"    service",[429,4421,639],{"class":509},[429,4423,4364],{"class":548},[429,4425,394],{"class":541},[429,4427,915],{"class":509},[429,4429,4430],{"class":541},"(test_client.",[429,4432,870],{"class":579},[429,4434,934],{"class":541},[429,4436,4437,4440,4442,4444],{"class":431,"line":568},[429,4438,4439],{"class":541},"    test_client.",[429,4441,870],{"class":579},[429,4443,394],{"class":541},[429,4445,692],{"class":579},[429,4447,4448],{"class":431,"line":573},[429,4449,519],{"emptyLinePlaceholder":9},[429,4451,4452,4455,4458,4461,4463,4466,4469,4472,4475,4477,4479],{"class":431,"line":583},[429,4453,4454],{"class":579},"    expect",[429,4456,4457],{"class":541},"(service.",[429,4459,4460],{"class":579},"new_checkout_enabled?",[429,4462,650],{"class":541},[429,4464,4465],{"class":439},"\"user-123\"",[429,4467,4468],{"class":541},")).",[429,4470,4471],{"class":579},"to",[429,4473,4474],{"class":579}," be",[429,4476,650],{"class":541},[429,4478,1871],{"class":548},[429,4480,934],{"class":541},[429,4482,4483],{"class":431,"line":601},[429,4484,519],{"emptyLinePlaceholder":9},[429,4486,4487,4489,4492,4494,4496,4498,4500],{"class":431,"line":607},[429,4488,4439],{"class":541},[429,4490,4491],{"class":579},"set_value",[429,4493,650],{"class":541},[429,4495,2166],{"class":439},[429,4497,462],{"class":541},[429,4499,1875],{"class":548},[429,4501,934],{"class":541},[429,4503,4504,4506,4508,4510,4512,4514,4516,4518,4520,4522,4524],{"class":431,"line":612},[429,4505,4454],{"class":579},[429,4507,4457],{"class":541},[429,4509,4460],{"class":579},[429,4511,650],{"class":541},[429,4513,4465],{"class":439},[429,4515,4468],{"class":541},[429,4517,4471],{"class":579},[429,4519,4474],{"class":579},[429,4521,650],{"class":541},[429,4523,1875],{"class":548},[429,4525,934],{"class":541},[429,4527,4528],{"class":431,"line":620},[429,4529,519],{"emptyLinePlaceholder":9},[429,4531,4532,4534,4536,4538],{"class":431,"line":626},[429,4533,4439],{"class":541},[429,4535,870],{"class":579},[429,4537,394],{"class":541},[429,4539,1539],{"class":579},[429,4541,4542],{"class":431,"line":632},[429,4543,604],{"class":509},[429,4545,4546],{"class":431,"line":669},[429,4547,749],{"class":509},[383,4549,4550,4553,4554,4557,4558,4560,4561,4563,4564,4566],{},[411,4551,4552],{},"test_client.client"," is a ",[411,4555,4556],{},"ConfigDirector::ConfigDirectorClient",", so it goes anywhere your code accepts one. It starts not ready, like a production client, because the code under test usually owns the call to ",[411,4559,490],{},"; unless initialization is held or set to fail, ",[411,4562,490],{}," serves the stored values at once. The test client has no ",[411,4565,715],{}," of its own: close its client when the test ends.",[816,4568,4570],{"id":4569},"clients-created-on-first-use","Clients created on first use",[383,4572,4573,4574,4576],{},"The setup code creates its client the first time a process reads a config, so a test can put the test client in place before that. Make ",[411,4575,824],{}," return the test client's client, and forget the module's client after each example, so the next example creates its own:",[419,4578,4581],{"className":500,"code":4579,"filename":4580,"language":371,"meta":425,"style":425},"RSpec.shared_context \"with a test client\" do\n  let(:test_client) { ConfigDirector::Testing.create_test_client({ \"new-checkout\" => true }) }\n\n  before { allow(ConfigDirector).to receive(:create_client).and_return(test_client.client) }\n\n  after do\n    test_client.client.close\n    ConfigDirectorClientPerProcess.instance_variable_set(:@client, nil)\n  end\nend\n","spec\u002Fsupport\u002Ftest_client_in_place_of_the_application_client.rb",[411,4582,4583,4597,4631,4635,4672,4676,4683,4693,4713,4717],{"__ignoreMap":425},[429,4584,4585,4587,4589,4592,4595],{"class":431,"line":432},[429,4586,4356],{"class":548},[429,4588,394],{"class":541},[429,4590,4591],{"class":579},"shared_context",[429,4593,4594],{"class":439}," \"with a test client\"",[429,4596,2657],{"class":509},[429,4598,4599,4602,4604,4607,4610,4612,4614,4616,4618,4620,4622,4624,4626,4628],{"class":431,"line":516},[429,4600,4601],{"class":579},"  let",[429,4603,650],{"class":541},[429,4605,4606],{"class":548},":test_client",[429,4608,4609],{"class":541},") { ",[429,4611,3842],{"class":548},[429,4613,907],{"class":541},[429,4615,4390],{"class":548},[429,4617,394],{"class":541},[429,4619,4395],{"class":579},[429,4621,4398],{"class":541},[429,4623,2166],{"class":439},[429,4625,2169],{"class":541},[429,4627,1871],{"class":548},[429,4629,4630],{"class":541}," }) }\n",[429,4632,4633],{"class":431,"line":522},[429,4634,519],{"emptyLinePlaceholder":9},[429,4636,4637,4640,4643,4645,4647,4650,4652,4655,4657,4660,4662,4665,4667,4669],{"class":431,"line":529},[429,4638,4639],{"class":541},"  before { ",[429,4641,4642],{"class":579},"allow",[429,4644,650],{"class":541},[429,4646,3842],{"class":548},[429,4648,4649],{"class":541},").",[429,4651,4471],{"class":579},[429,4653,4654],{"class":579}," receive",[429,4656,650],{"class":541},[429,4658,4659],{"class":548},":create_client",[429,4661,4649],{"class":541},[429,4663,4664],{"class":579},"and_return",[429,4666,4430],{"class":541},[429,4668,870],{"class":579},[429,4670,4671],{"class":541},") }\n",[429,4673,4674],{"class":431,"line":538},[429,4675,519],{"emptyLinePlaceholder":9},[429,4677,4678,4681],{"class":431,"line":557},[429,4679,4680],{"class":541},"  after ",[429,4682,2615],{"class":509},[429,4684,4685,4687,4689,4691],{"class":431,"line":568},[429,4686,4439],{"class":541},[429,4688,870],{"class":579},[429,4690,394],{"class":541},[429,4692,1539],{"class":579},[429,4694,4695,4697,4699,4702,4704,4707,4709,4711],{"class":431,"line":573},[429,4696,2771],{"class":548},[429,4698,394],{"class":541},[429,4700,4701],{"class":579},"instance_variable_set",[429,4703,650],{"class":541},[429,4705,4706],{"class":548},":@client",[429,4708,462],{"class":541},[429,4710,1766],{"class":548},[429,4712,934],{"class":541},[429,4714,4715],{"class":431,"line":583},[429,4716,604],{"class":509},[429,4718,4719],{"class":431,"line":601},[429,4720,749],{"class":509},[383,4722,4723,4724,4727,4728,4730],{},"The first read of an example then goes through ",[411,4725,4726],{},"ConfigDirectorClientPerProcess"," as it does in production: it creates the client, which is the test client's, and calls ",[411,4729,490],{},", which serves the stored values at once.",[816,4732,4733],{"id":1154},"Values",[383,4735,4736,462,4738,466,4740,4743,4744,838,4746,4748,4749,4751,4752,4755,4756,4758,4759,4761],{},[411,4737,4395],{},[411,4739,4491],{},[411,4741,4742],{},"replace_values"," take Ruby values, and the config type follows from the class of each value: ",[411,4745,1871],{},[411,4747,1875],{}," is a boolean config, an Integer an integer config, a Float a float config, a String a string config, and a Hash or an Array a JSON config, which can hold ",[411,4750,1766],{},". A key is a String or a Symbol, and a Symbol is read as its name. A String is always a string config, so JSON text meant as a JSON config is given as ",[411,4753,4754],{},"JSON.parse(text)",". Every value is served as an unconditional config, so every context receives the same value; a test that needs different values per context is written as one test per value. A value the SDK cannot serve, such as ",[411,4757,1766],{},", a Symbol or a Float that is not finite, raises ",[411,4760,802],{},", and so does a blank key or a key of another class. Nothing changes then.",[383,4763,4764,4765,4768,4769,4771,4772,4775,4776,4778,4779,4782,4783,4785,4786,466,4788,4790],{},"Reads behave as they do in production: ",[411,4766,4767],{},"set_value(\"new-checkout\", true)"," read with a String in-code default value returns that in-code default value with the ",[411,4770,1886],{}," reason, ",[411,4773,4774],{},"set_value(\"max-items\", 2.5)"," read with an Integer returns it with the ",[411,4777,1861],{}," reason, and ",[411,4780,4781],{},"set_value(\"banner-text\", \"\")"," returns it with the ",[411,4784,1892],{}," reason. ",[411,4787,1729],{},[411,4789,1942],{}," handlers report the reason. A Hash keeps its order.",[816,4792,4794],{"id":4793},"controls","Controls",[3979,4796,4797,4807],{},[3982,4798,4799],{},[3985,4800,4801,4804],{},[3988,4802,4803],{},"Control",[3988,4805,4806],{},"Effect",[3995,4808,4809,4827,4850,4863,4886,4904,4932],{},[3985,4810,4811,4816],{},[4000,4812,4813],{},[411,4814,4815],{},"set_value(key, value)",[4000,4817,4818,4819,4821,4822,4291,4824,4826],{},"Stores the value and, while the client is connected, delivers an update carrying only ",[411,4820,1631],{},". Reads, the watches of ",[411,4823,1631],{},[411,4825,1686],{}," handlers see it before the call returns.",[3985,4828,4829,4834],{},[4000,4830,4831],{},[411,4832,4833],{},"remove_value(key)",[4000,4835,4836,4837,4839,4840,4842,4843,4845,4846,2583,4848,394],{},"Removes the value and delivers a full update without it. Reads return the in-code default value with the ",[411,4838,1855],{}," reason, the watches of ",[411,4841,1631],{}," receive the in-code default value, and ",[411,4844,1686],{}," handlers find ",[411,4847,1631],{},[411,4849,1711],{},[3985,4851,4852,4857],{},[4000,4853,4854],{},[411,4855,4856],{},"replace_values(values)",[4000,4858,4859,4860,4862],{},"Replaces every stored value, cancels a hold or a failure that no ",[411,4861,490],{}," has used yet, and delivers a full update. Use it to reset a test client shared between tests.",[3985,4864,4865,4870],{},[4000,4866,4867],{},[411,4868,4869],{},"hold_initialization",[4000,4871,4872,4873,4875,4876,838,4879,4882,4883,4885],{},"The next ",[411,4874,490],{}," waits until another thread calls ",[411,4877,4878],{},"complete_initialization",[411,4880,4881],{},"fail_initialization",", or until the timeout. ",[411,4884,490],{}," blocks, so a test calls it on another thread.",[3985,4887,4888,4892],{},[4000,4889,4890],{},[411,4891,4878],{},[4000,4893,4894,4895,4897,4898,4900,4901,4903],{},"Delivers the stored values to the held ",[411,4896,490],{},", on the calling thread, so the client is ready when the call returns. The held ",[411,4899,490],{}," returns once the handlers and watches of those values have run. Called before ",[411,4902,490],{}," while a hold is set, it cancels the hold.",[3985,4905,4906,4910],{},[4000,4907,4908],{},[411,4909,4881],{},[4000,4911,4912,4913,4915,4916,4918,4919,4922,4923,4925,4926,4928,4929,4931],{},"Fails the held ",[411,4914,490],{}," the way a refused server SDK key does: the client is not ready, an error is logged and the ",[411,4917,781],{}," handlers receive a ",[411,4920,4921],{},"ConfigDirectorConnectionError"," with the status 401, on the calling thread, and then the held ",[411,4924,490],{}," returns. Called while no ",[411,4927,490],{}," is held, it makes the next ",[411,4930,490],{}," fail, which then returns at once.",[3985,4933,4934,4939],{},[4000,4935,4936],{},[411,4937,4938],{},"tracked_events",[4000,4940,4941,4942,4944,4945,1788,4948,462,4950,462,4952,466,4954,4956,4957,4959,4960,4962,4963,4966],{},"The events the code under test tracked with ",[411,4943,3708],{},", in call order, each as a ",[411,4946,4947],{},"ConfigDirector::Testing::TrackedEvent",[411,4949,1794],{},[411,4951,1898],{},[411,4953,1647],{},[411,4955,3722],{},". An event whose name the SDK would not report is not recorded, and a value or details the SDK would leave out are ",[411,4958,1766],{}," in the record. The details are recorded as the SDK sends them, so their keys are Strings and a ",[411,4961,3918],{}," is its ISO 8601 text in UTC. The limit of 1,000 events per telemetry report does not apply to the record, and nothing is recorded once the client is closed. It is the same Array on every call, so ",[411,4964,4965],{},"test_client.tracked_events.clear"," empties it.",[383,4968,857,4969,4971],{},[411,4970,490],{}," after a failed one serves the stored values, the ones set in the meantime included.",[419,4973,4975],{"className":500,"code":4974,"filename":4338,"language":371,"meta":425,"style":425},"it \"shows the old checkout when ConfigDirector refuses the key\" do\n  test_client = ConfigDirector::Testing.create_test_client({ \"new-checkout\" => true }, timeout: 0.5)\n  service = CheckoutService.new(test_client.client)\n  test_client.fail_initialization\n\n  test_client.client.init\n\n  expect(test_client.client.ready?).to be(false)\n  expect(service.new_checkout_enabled?(\"user-123\")).to be(false)\n  test_client.client.close\nend\n",[411,4976,4977,4987,5022,5041,5049,5053,5063,5067,5092,5116,5126],{"__ignoreMap":425},[429,4978,4979,4982,4985],{"class":431,"line":432},[429,4980,4981],{"class":541},"it ",[429,4983,4984],{"class":439},"\"shows the old checkout when ConfigDirector refuses the key\"",[429,4986,2657],{"class":509},[429,4988,4989,4992,4994,4996,4998,5000,5002,5004,5006,5008,5010,5012,5015,5017,5020],{"class":431,"line":516},[429,4990,4991],{"class":635},"  test_client",[429,4993,639],{"class":509},[429,4995,642],{"class":548},[429,4997,907],{"class":541},[429,4999,4390],{"class":548},[429,5001,394],{"class":541},[429,5003,4395],{"class":579},[429,5005,4398],{"class":541},[429,5007,2166],{"class":439},[429,5009,2169],{"class":541},[429,5011,1871],{"class":548},[429,5013,5014],{"class":541}," }, ",[429,5016,1290],{"class":548},[429,5018,5019],{"class":548}," 0.5",[429,5021,934],{"class":541},[429,5023,5024,5027,5029,5031,5033,5035,5037,5039],{"class":431,"line":522},[429,5025,5026],{"class":635},"  service",[429,5028,639],{"class":509},[429,5030,4364],{"class":548},[429,5032,394],{"class":541},[429,5034,915],{"class":509},[429,5036,4430],{"class":541},[429,5038,870],{"class":579},[429,5040,934],{"class":541},[429,5042,5043,5046],{"class":431,"line":529},[429,5044,5045],{"class":541},"  test_client.",[429,5047,5048],{"class":579},"fail_initialization\n",[429,5050,5051],{"class":431,"line":538},[429,5052,519],{"emptyLinePlaceholder":9},[429,5054,5055,5057,5059,5061],{"class":431,"line":557},[429,5056,5045],{"class":541},[429,5058,870],{"class":579},[429,5060,394],{"class":541},[429,5062,692],{"class":579},[429,5064,5065],{"class":431,"line":568},[429,5066,519],{"emptyLinePlaceholder":9},[429,5068,5069,5072,5074,5076,5078,5080,5082,5084,5086,5088,5090],{"class":431,"line":573},[429,5070,5071],{"class":579},"  expect",[429,5073,4430],{"class":541},[429,5075,870],{"class":579},[429,5077,394],{"class":541},[429,5079,806],{"class":579},[429,5081,4649],{"class":541},[429,5083,4471],{"class":579},[429,5085,4474],{"class":579},[429,5087,650],{"class":541},[429,5089,1875],{"class":548},[429,5091,934],{"class":541},[429,5093,5094,5096,5098,5100,5102,5104,5106,5108,5110,5112,5114],{"class":431,"line":583},[429,5095,5071],{"class":579},[429,5097,4457],{"class":541},[429,5099,4460],{"class":579},[429,5101,650],{"class":541},[429,5103,4465],{"class":439},[429,5105,4468],{"class":541},[429,5107,4471],{"class":579},[429,5109,4474],{"class":579},[429,5111,650],{"class":541},[429,5113,1875],{"class":548},[429,5115,934],{"class":541},[429,5117,5118,5120,5122,5124],{"class":431,"line":601},[429,5119,5045],{"class":541},[429,5121,870],{"class":579},[429,5123,394],{"class":541},[429,5125,1539],{"class":579},[429,5127,5128],{"class":431,"line":607},[429,5129,749],{"class":509},[816,5131,5133],{"id":5132},"options","Options",[383,5135,5136,5139,5140,5142,5143,5145,5146,5148,5149,5151,5152,5154],{},[411,5137,5138],{},"create_test_client(values, timeout: nil, logger: nil)"," takes ",[411,5141,465],{},", in seconds, which bounds how long a held ",[411,5144,490],{}," waits and defaults to the SDK's production timeout of 3 seconds; and ",[411,5147,449],{},", any object with the methods of Ruby's ",[411,5150,965],{},", as ",[411,5153,824],{}," takes it. Without a logger the SDK writes warnings and errors to standard error.",[816,5156,5158],{"id":5157},"what-to-expect","What to expect",[771,5160,5161,5176,5191,5209,5218,5226,5234],{},[478,5162,5163,5164,5166,5167,5169,5170,5172,5173,5175],{},"The first values are delivered while ",[411,5165,490],{}," runs, so watches registered before ",[411,5168,490],{}," run before it returns, and the ",[411,5171,1686],{}," handlers run before the ",[411,5174,1674],{}," handlers.",[478,5177,5178,5179,462,5181,462,5184,462,5186,838,5188,5190],{},"Watches and handlers run on the thread that calls ",[411,5180,4491],{},[411,5182,5183],{},"remove_value",[411,5185,4742],{},[411,5187,4878],{},[411,5189,490],{},", never on a thread of the SDK, so an assertion can follow the call directly. A change made from inside a handler or a watch is delivered right after the one being handled.",[478,5192,5193,5194,5196,5197,5199,5200,5202,5203,5205,5206,5208],{},"A held ",[411,5195,490],{}," that reaches the timeout logs the SDK's timeout warning, and a client that was not ready stays not ready until the next ",[411,5198,490],{},". A client that was ready keeps serving its values through a later held or failed ",[411,5201,490],{},", and completing such an ",[411,5204,490],{}," calls no ",[411,5207,1674],{}," handler.",[478,5210,5211,5212,5214,5215,5217],{},"Each failed ",[411,5213,490],{}," calls the ",[411,5216,781],{}," handlers, where a client connected to ConfigDirector calls them at most once.",[478,5219,5220,5221,466,5223,5225],{},"Watches run for every update that carries their key, whether or not the value changed, as in production. ",[411,5222,5183],{},[411,5224,4742],{}," deliver a full update, so they also run the watches of every key left.",[478,5227,4026,5228,5230,5231,5233],{},[411,5229,1946],{}," a watch or a handler raises is logged and does not reach the caller, as in production. An exception that is not a ",[411,5232,1946],{},", such as a failed RSpec expectation, reaches the call that delivered the change.",[478,5235,5236,5237,462,5239,5241,5242,5244,5245,799,5247,5250],{},"After ",[411,5238,715],{},[411,5240,806],{}," is false, every read returns its in-code default value, ",[411,5243,4184],{}," returns an empty Hash, ",[411,5246,490],{},[411,5248,5249],{},"ConfigDirectorValidationError",", every handler and watch has been removed, and the closed client takes none of the values the test client's controls store.",[5252,5253,5254],"style",{},"html pre.shiki code .sA9AF, html code.shiki .sA9AF{--shiki-light:#702C00;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .suztq, html code.shiki .suztq{--shiki-light:#032563;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sLDKn, html code.shiki .sLDKn{--shiki-light:#A0111F;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sM45V, html code.shiki .sM45V{--shiki-light:#66707B;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sbRM4, html code.shiki .sbRM4{--shiki-light:#0E1116;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sxMNI, html code.shiki .sxMNI{--shiki-light:#023B95;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sEIia, html code.shiki .sEIia{--shiki-light:#622CBC;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .syyZu, html code.shiki .syyZu{--shiki-light:#702C00;--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .spee4, html code.shiki .spee4{--shiki-light:#A0111F;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sa4_4, html code.shiki .sa4_4{--shiki-light:#024C1A;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sT_Me, html code.shiki .sT_Me{--shiki-light:#023B95;--shiki-default:#6F42C1;--shiki-dark:#B392F0}",{"title":425,"searchDepth":516,"depth":516,"links":5256},[5257,5258,5259,5264,5270,5274,5275,5283],{"id":381,"depth":516,"text":5},{"id":397,"depth":516,"text":398},{"id":472,"depth":516,"text":473,"children":5260},[5261,5262,5263],{"id":818,"depth":522,"text":819},{"id":1441,"depth":522,"text":1442},{"id":1969,"depth":522,"text":1130},{"id":2298,"depth":516,"text":393,"children":5265},[5266,5267,5268,5269],{"id":2315,"depth":522,"text":2316},{"id":2327,"depth":522,"text":2328},{"id":2360,"depth":522,"text":2361},{"id":2631,"depth":522,"text":2632},{"id":2830,"depth":516,"text":2831,"children":5271},[5272,5273],{"id":3145,"depth":522,"text":3146},{"id":3549,"depth":522,"text":3550},{"id":3702,"depth":516,"text":3703},{"id":4042,"depth":516,"text":4043,"children":5276},[5277,5278,5279,5280,5281,5282],{"id":1729,"depth":522,"text":1729},{"id":4161,"depth":522,"text":806},{"id":4175,"depth":522,"text":4178},{"id":4184,"depth":522,"text":4184},{"id":4283,"depth":522,"text":4283},{"id":715,"depth":522,"text":715},{"id":4322,"depth":516,"text":4323,"children":5284},[5285,5286,5287,5288,5289],{"id":4569,"depth":522,"text":4570},{"id":1154,"depth":522,"text":4733},{"id":4793,"depth":522,"text":4794},{"id":5132,"depth":522,"text":5133},{"id":5157,"depth":522,"text":5158},"Evaluate configs and feature flags locally for any context with the Ruby server SDK, with updates delivered over server sent events to every process of your application, forked workers included","md",null,{"modifiedAt":5294},"2026-11-19T18:10:37.000Z",{"title":206,"icon":209},{"title":364,"description":5290},"iD1rwPJMHnKk8dmeRVZmEVl9FaLHRU1lZQLJTt4cbUY",[5299,5301],{"title":201,"path":202,"stem":203,"description":5300,"icon":204,"children":-1},"Evaluate configs and feature flags locally for any context with the PHP server SDK, which keeps the values it receives in a local store that the PHP processes of a host share",{"title":55,"path":213,"stem":214,"description":5302,"icon":212,"children":-1},"Use ConfigDirector through the vendor-neutral OpenFeature API. The providers for the web, Swift, Android, Flutter, Node.js, Python, Java, .NET, Go, PHP, and Ruby, how the evaluation context and the getters map onto ConfigDirector, and what to expect from initialization, events, and tests.",1795111940942]