Repository navigation
Job actions: react, read and view, on one paced, persistent op-layer execution model - #45
Merged
Merged
Conversation
…, an hourly cap and a flood slow-down
…_contact and chat_is_new
… op runner for job actions
…er-account scheduler Every action, forward and reply included, now runs as an operation through dispatch.execute, so jobs get policy, rate limits, flood budgets and self-origin events. Adds react, read and view; delays never block a bus lane, each action kind has its own pacer, and reads and views coalesce.
…h validation error
…and validation in add and reload job queue list shows every pending action with its due time and state; job queue cancel drops by id, --chat, --job or --all and is destructive, so it needs --yes off a terminal. A bare 'tlgr job queue' lists. job add and job reload --validate-only now run the engine's own parser.
…parser; key edits by edit time
… DM example and the design decisions
…stead of giving up after two minutes
…lay is still recognised
…ead of letting it die
…over to forum topics, and tighten retries, batching and saving From review: a disconnect cancelled the in-flight request and ended that kind's worker for good; a read in one forum topic dropped items in others; the read the server makes when tlgr sends looked like a takeover. Also: floods have their own counter, a running item of a removed job is not requeued, batches skip expired and quiet-held siblings, the debounced save runs in a thread, waits re-check the wall clock every minute, and presence recovers if an action starts while going offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three new gateway job actions,
react,readandview, and one execution model for every action,forwardandreplyincluded:message.forward,message.send,media.upload,reaction.add,message.read,message.view.get,chat.typing,profile.presence.set) viadispatch.execute, in process, for the job's account. Jobs now get policy allow/deny, the rate limiter, flood budgets, self-origin events and the per-peer edge cases the ops already handle.percentroll, processors, emoji pick) and queuesPendingItems on the account'sActionScheduler; the handler returns at once.delay,percent,presence(leave,blip,session,quiet_hours),on_takeover(cancel,cancel_read,ignore),dry_run. Defaults keep existing jobs doing what they did, apart from pacing.pacing:block. FLOOD_WAIT reschedules and slows the queue, transient errors retry, permanent ones are counted.accounts/<alias>/pending.json(0600, atomic, bounded at 10 000): pending actions survive restarts and crashes and resume at their original due time. React, view and reply expire after 24 h (configurable). Recently finished keys stop a replayed update from being acted on twice.custom:<id>, replaces the previous reaction, reads first, one per album), read (up to the message, right RPC per peer, coalesced per chat, reading time,mentions/reactions), view (channel view increment, voice and round notes listened in DMs and groups, view-once untouched unless enabled), reply typing on by default.on_takeover; tlgr's own reads and sends are told apart by the ids it recorded.sender_is_contactandchat_is_new.tlgr job queue(list) andtlgr job queue cancel ID | --chat | --job | --all(destructive,--yesoff a terminal); per-action counters (done, skipped, superseded, expired, pending, errors) injob list,job getanddaemon status; strict validation injob add,job reload --validate-onlyandconfig validate.Why
The main use case is DMs: read, listen, react and answer the way a person does, without blocking the bus and without hammering the account. Moving
forwardandreplyonto the same path removes the last places where a job called Telethon directly, outside policy and rate limits.Decisions
Recorded in
docs/design/JOB_ACTIONS.md. In short:[every, 1.5 x every], soeveryis a floor.flood.json), debounced writes plus a final write at shutdown, read before any job can submit.GroupedMedia::itemForTextand AndroidfindPrimaryMessageObject; an album is one percent roll.leavenever sends anything; account-level[presence] modeother thanoffdisables job presence. Quiet hours use[defaults] timezone, else local time, and release spread over 5 minutes.job reload.tlgr job queueisjob.queue.listtaggedgroup-default(the registry forbids an id that is also a group);job.getmoved to the daemon surface to show live counters;job disabledrops what the job had queued.Behaviour changes for existing jobs
Tests
New:
test_gateway_knobs.py,test_gateway_pacer.py,test_gateway_scheduler.py,test_gateway_config.py,test_filters_dialog.py,test_job_queue.py; portedtest_gateway.py,test_gateway_bus.py,test_actions.pyto the new path;test_daemon_jobs.pycovers save at shutdown and resume at boot. Real TL types throughout, a virtual clock for pacing (no real sleeps), and end-to-end runs through the daemon's dispatcher against the fake client (forward, processed re-send of text and media, reply with typing, react after read, per-peer read RPCs including forum topics, channel views).make lint typecheck test docs paritypasses locally (13 546 tests), and the relevant suites pass on Python 3.10 as well.