-
Notifications
You must be signed in to change notification settings - Fork 13
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
New task execution framework #107
Merged
Merged
Conversation
This file contains 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
Prnyself
reviewed
Sep 23, 2019
Prnyself
reviewed
Sep 23, 2019
Xuanwo
added a commit
that referenced
this pull request
Oct 25, 2019
* misc: Upgrade navvy * Refactor relation between task and cmd * task: Add support for upload local file * task/types: Add check before get value * task/copy: Implement copy from stram/file to object * task/common: Move mulptipart and object operation to common * task: Split copy into copy_file and copy_stream * task/utils: Remove not used funcs * task: Rename FilePath to Path * task: Generate task definitions * task: Auto generate inherited value code * task: Add copy root task * task: Add ParseTowArgs and SetupStorage * task: Add test for file task * task/types: Add more clear info for get invalid value * task/common: Add md5sum test * task/common: Add test for multipart * travis: Use go 1.13 instead * task/copy_file: Add test for copy file tasks * task/copy_stream: Add test for copy stream task * utils: Add stream input support * action: Remove not used tests * task/utils: Move PraseInput into task * task/tools: Format input json * task: Add requirnment for dependent task * task/tools: Refactor template * task/tools: Do not add name in json file * Fix conflict
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.
This pr will introduce a new task execution framework which could be exported to another project, and serves both qsctl and qscamel.
Situation
We do need concurrency.
it's 9102 for now, we have more cores and faster networks. We need to make our best to improve user experience and speed is one of the most importent parts. So we need concurrency here.
We do need tests.
qsctl
is the tool with the most users for qingstor object storage. And problem happened will make users angry, even affecting their business and data. So we need to test our tools for every single operation.We do need happiness.
developers are also human beings(it's obviously before we got AI coding for us). So developer experience is as important as user experience. We need to make fun in developing qsctl. Less copy-and-paste, less interface type assertion by hand, less panic in runtime, less possibility to fix bug on holiday.
Goal
Concept
Type
Type
will be used to do two things:Every type will be like following:
Firstly, we got a struct with typed value(not interface) and valid marker. Then we have
GetXXX
andSetXXX
functions with typed value as arguements. After these, we can haveXXXGetter
andXXXSetter
to describe abilities that task have.Task
Every task implements
navvy.Task
interface which is a simplefunc(){}
. And task struct will be look like this:Types will be embed, so that we can use
t.GetPath()
instead oft.Path.GetPath()
.Task have two kind of value:
And there are two kind of tasks:
FileMD5SumTask
CopyFileTask
We need to write
run
for required task, andnew
for dependent task. In other opinion, required task will do the real job, dependent task will be a compose of different required tasks.Todo && Todoist
Todo
is a slice ofTodoFunc
, andTodoist
is the interface with following functions:Every task will have a Todo to manager it's job queue and submit self to the pool.
Implemention
Type
Type will be generated via
types.json
:Type will be shared across task pacakge.
Task
Task will be generated via
tasks.json
too:Review
Let's check whether we achieve our goals.
CopyLargeFile
as an example.mockXXXTask
which satisfiedXXXTaskRequirement
Roadmap
It's obviously that this framework is far from finished, but I think it's ready to be merged and we can bulid qsctl without waiting for the changes of this framework.
We will do following things for this framework:
That's all, thanks for reviewing.