Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify engine internals #3010

Merged
merged 5 commits into from
Nov 13, 2024
Merged

Simplify engine internals #3010

merged 5 commits into from
Nov 13, 2024

Commits on Nov 12, 2024

  1. engine: drop internal blockExec struct

    It's not used in any way as a struct.
    
    Signed-off-by: Roman Khimov <roman@nspcc.ru>
    roman-khimov committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    2baeb79 View commit details
    Browse the repository at this point in the history
  2. engine: drop e.execIfNotBlocked()

    That's where KISS and DRY get into a little conflict. My take is that KISS
    wins here:
     * it's five lines of code
     * yeah it's repetitive, but e.execIfNotBlocked() is repetitive as well with
       three lines of code minimum
     * it inherently requires lambdas
     * variables need to be defined and properly managed, some code looks a bit
       strange where we return (smth, error) and smth gets its value in a lambda,
       but error is the result of e.execIfNotBlocked()
     * in most cases it also leads to the need of additional "internal" functions
     * overall we get _less_ code after this patch
     * nothing hidden, clear execution flow
    
    Signed-off-by: Roman Khimov <roman@nspcc.ru>
    roman-khimov committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    255c9e5 View commit details
    Browse the repository at this point in the history
  3. engine: drop hashedShard type

    It's a simple alias since 6ad2624 and the
    only difference is an additional Hash() method that might as well be a part
    of shardWrapper method set. This also simplifies sortShardsByWeight, we don't
    need to hold the lock while sorting.
    
    Signed-off-by: Roman Khimov <roman@nspcc.ru>
    roman-khimov committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    9e6f9bb View commit details
    Browse the repository at this point in the history
  4. engine: drop iterateOverUnsortedShards and iterateOverSortedShards

    These _seriously_ complicate the code for zero reason. We have to:
     * create/pass some lambdas
     * mess with input/output variables
     * mess with iterator flow instead of shortcutting to exit
     * have fun with defers and named return variables
    
    Which leads to code bloat and increased cognitive load for developers. For
    what purpose? I have no idea, dropping them makes code much easier.
    
    Signed-off-by: Roman Khimov <roman@nspcc.ru>
    roman-khimov committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    209f9ce View commit details
    Browse the repository at this point in the history
  5. engine: unify GetRange implementation with Get

    A lot of the same code, the only difference is apistatus.ObjectOutOfRange
    handling which doesn't hurt for Get and is very much relevant for GetRange.
    
    Signed-off-by: Roman Khimov <roman@nspcc.ru>
    roman-khimov committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    99d4320 View commit details
    Browse the repository at this point in the history