API docs
Everything the lantern package exports, with a short example for each.
Contents
Client(**options)
Creates a client. Every option is optional:
| Option | Default | What it does |
|---|---|---|
source | "flags.json" | The file the rules are read from. |
refresh_interval | "60s" | How often the rules are read again. |
timeout | "2s" | How long a refresh may take before the old rules are kept. |
from lantern import Client
flags = Client(
source="flags.json",
)flags.is_enabled(flag, context)
Reports whether a flag is on for the given user or request.
flags.is_enabled("dark-mode", user_id=7)flags.variant(flag, context)
Returns the variant a user is assigned to, for flags with more than two options.
plan = flags.variant("pricing-page", user_id=7)flags.override(flag, value)
Forces a flag on or off in this process, for tests and local work.
flags.override("new-checkout", True)flags.refresh()
Reads the latest rules right away instead of waiting for the next interval.
flags.refresh()flags.close()
Stops the background refresh.
flags.close()