Skip to content

Jobs - #12970

Closed
hansl wants to merge 0 commit into
angular:masterfrom
hansl:jobs-pr
Closed

Jobs#12970
hansl wants to merge 0 commit into
angular:masterfrom
hansl:jobs-pr

Conversation

@hansl

@hansl hansl commented Nov 15, 2018

Copy link
Copy Markdown
Contributor

There is a README added which contains how to use the API.

@hansl
hansl force-pushed the jobs-pr branch 2 times, most recently from d680391 to efb33cb Compare November 15, 2018 22:09
@angular angular deleted a comment from ngbot Bot Nov 15, 2018
@hansl hansl added the target: major This PR is targeted for the next major release label Nov 16, 2018
@hansl
hansl force-pushed the jobs-pr branch 2 times, most recently from 7e99cd1 to fe37416 Compare November 16, 2018 20:50
const yarnInstall = jobs.createJob(/* ... */, { name: 'yarn-install', extends: dispatcher });
const pnpmInstall = jobs.createJob(/* ... */, { name: 'pnpm-install', extends: dispatcher });

declare const registry: jobs.SimpleJobRegistry;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare here is not correct, since you are not writing a declaration file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example in the README. It's meant to provide context on the type, not be copy-pasted as is.

# Jobs

Jobs is the Angular DevKit subsystem for scheduling and running generic functions with clearly
typed inputs and outputs. A Job is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A Job is" is not a sentence, would ❤️ to see a longer definition here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarifying this. I'm reworking the README a bit and by EOD I'll have a proper description to replace that non-sentence.

@clydin clydin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part 1

Comment thread packages/angular_devkit/core/node/scheduler.ts Outdated
Comment thread packages/angular_devkit/core/node/scheduler.ts Outdated
import { jobs, schema } from '../src';
import { ModuleNotFoundException, resolve } from './resolve';

export class NodeModuleJobScheduler extends jobs.SimpleScheduler {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making a JobRegistry interface that a scheduler would then use. Job discovery and job scheduling are really orthogonal tasks. Subclassing a scheduler wouldn't typically be needed then and being able to compose registries would provide for interesting behavioral options as well.

Comment thread packages/angular_devkit/core/src/jobs/api.ts Outdated
});

// Extending makes sure the input and output matches the dispatcher.
const npmInstall = jobs.createJob(/* ... */, { name: 'npm-install', extends: dispatcher });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extends feels wrong semantically. implements? handles? provides?

Actually, is this option even needed? The dispatcher is the element that requires the knowledge of the connection between the new job and itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm starting to think that extends as a concept is specific to the registry and should not be part of the job declaration. It was deeper integrated with the API and then I moved it slowly out of it. I think I should remove it entirely (and keep it as a field in the register() functions).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to go with implements, as it's more an interface related concept.

* Metadata associated with a job.
*/
export interface JobDescription extends JsonObject {
readonly name: JobName;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use string here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm naming this as a hint that everywhere that type is used should be the job name itself and not just a random string (like a message). This is used as a hint ot users, not actually typing.

return s;
}),
inputChannel: inputChannel.asObservable(),
logger,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the logger come from the context?

@hansl hansl Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no logger in the Job interface, only a JobEvent kind of Log. The context passed in the createJob handler is expanded, there's no logger in the Job api by default (and by design)

@filipesilva filipesilva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review of the readme.

Reading through the description, Jobs could also find a home in the benchmark tool. The benchmark tool is doing very similar things with scheduling individual runs, including the multiple output observables.

Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
1. `id`. A unique symbol that can be used as a Map key.
1. `description`. The description of the job from the scheduler. See `JobDescription` object.
1. `input`. An `Observer` that can be used to send validated inputs to the Job itself.
1. `output`. An `Observable<OutputType>` that filters out events to get only the returned output

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does filters out events to get only the returned output mean? I don't understand which events these are.

Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Comment thread packages/angular_devkit/core/src/jobs/README.md Outdated
Jobs can be scheduled using a `Scheduler` interface, which contains a `schedule()` method. The
method takes a name, an input and a list of options.

## Synchronizing and Dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't synchronization managed by the execution strategy?

Are these different things, and if so, what are the different use cases?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are different things. The difference is that strategy is set by the actual Job code, while this synchronization is done by the person scheudling the job. Clarfiied.

@angular angular deleted a comment from ngbot Bot Nov 21, 2018
@hansl hansl closed this Nov 21, 2018
@hansl

hansl commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

Sorry guys I've pushed master to this branch instead of pulled my branch to my computer this morning. This is going to be one of those days... 😩

@hansl

hansl commented Nov 22, 2018

Copy link
Copy Markdown
Contributor Author

Moved to #13029.

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants