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

Factor out duplicate getOrStartWorker into BrokerController #797

Open
trevorgerhardt opened this issue Apr 1, 2022 · 0 comments
Open

Factor out duplicate getOrStartWorker into BrokerController #797

trevorgerhardt opened this issue Apr 1, 2022 · 0 comments
Labels
cleanup t0 Time level 0: think hours

Comments

@trevorgerhardt
Copy link
Member

This code is mostly a duplicate of the code in the BrokerController (in fact it was originally copied from there). Should we abstract this out as a helper method in the broker itself?

   /**
     * Get or start worker.
     */
    public synchronized String getOrStartWorker(WorkerCategory workerCategory, WorkerTags workerTags) {
        String address = getWorkerAddress(workerCategory);
        if (address == null) {
            // There are no workers that can handle this request. Request some.
            createOnDemandWorkerInCategory(workerCategory, workerTags);
        } else {
            // Workers exist in this category, clear out any record that we're waiting for one to start up.
            // FIXME the tracking of which workers are starting up should really be encapsulated using a "start up if needed" method.
            recentlyRequestedWorkers.remove(workerCategory);
        }
        return address;
    }

At the very least, we shouldn't leave the replicated FIXME in two different places.

Originally posted by @trevorgerhardt in #782 (comment)

@trevorgerhardt trevorgerhardt added cleanup t0 Time level 0: think hours labels Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup t0 Time level 0: think hours
Projects
None yet
Development

No branches or pull requests

1 participant