Backblaze / boardwalk

A linear remote execution workflow engine built on top of Ansible
Other
18 stars 1 forks source link

Constrain the maximum events per workspace on state flush #44

Closed asullivan-blze closed 1 year ago

asullivan-blze commented 1 year ago

Resolves #5.

What and why?

The Python documentation says that initializing a deque object in the manner of deque([], maxlen), where maxlen is the maximum number of items the deque object should hold, pops old elements from the left when a new element is added to the right. For some reason, this isn't how it seems to be operating in the current implementation. So we can just iterate through the entire state on flush for each workspace, check the length of the event deque, and if greater than the desired quantity of events, pop the excess from the left (thus dropping old events).

How was this tested?

make develop-server, with debug code to view the workspace(s), and the length of the events deque. Verified through execution of the ShouldFailTestWorkspace and ShouldSucceedTestWorkspace that events beyond 64 (_MAXIMUM_EVENTS) get dropped via the debug lines. (Which were removed prior to merge.)

Checklist