-
Notifications
You must be signed in to change notification settings - Fork 0
feature-complete interface #8
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
Open
krisbitney
wants to merge
2
commits into
main
Choose a base branch
from
kris/feature-complete-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| node_modules | ||
| wrap/ | ||
| .polywrap/ | ||
| .polywrap/ | ||
| build/ |
Binary file not shown.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| { | ||
| "name": "@polywrap/concurrent-interface", | ||
| "description": "Concurrent interface", | ||
| "private": true, | ||
| "name": "@polywrap/concurrency-interface", | ||
| "description": "Polywrap Concurrency Interface", | ||
| "version": "0.10.0", | ||
| "scripts": { | ||
| "build": "npx polywrap build", | ||
| "deploy": "npx polywrap deploy -o ./deployment.json" | ||
| "deploy": "npx polywrap deploy -o deployment.json" | ||
| }, | ||
| "devDependencies": { | ||
| "polywrap": "0.10.2" | ||
| "polywrap": "0.10.3" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| format: 0.1.0 | ||
| stages: | ||
| format: 0.2.0 | ||
| jobs: | ||
| ipfs_deploy: | ||
| package: ipfs | ||
| uri: fs/./build | ||
| config: | ||
| gatewayUri: https://ipfs.wrappers.io | ||
| steps: | ||
| - name: ipfs_deploy | ||
| package: ipfs | ||
| uri: fs/./build | ||
| config: | ||
| gatewayUri: https://ipfs.wrappers.io |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,149 @@ | ||
| """ | ||
| Indicates the current status of a task. | ||
| """ | ||
| enum TaskStatus { | ||
| PENDING # applicable when running in pool | ||
| RUNNING | ||
| COMPLETED | ||
| CANCELLED # applicable when threads/processes are used | ||
| FAILED | ||
| """ | ||
| Task is scheduled but not yet running. This status is typically applicable when tasks are queued to run in a pool. | ||
| """ | ||
| PENDING | ||
| """ | ||
| Task is currently executing. | ||
| """ | ||
| RUNNING | ||
| """ | ||
| Task execution has been paused. | ||
| """ | ||
| SUSPENDED | ||
| """ | ||
| Task has completed execution successfully. | ||
| """ | ||
| COMPLETED | ||
| """ | ||
| Task execution has been cancelled before completion. This status is typically applicable when threads or processes are used and are aborted before they complete. | ||
| """ | ||
| CANCELLED | ||
| """ | ||
| Task has failed to execute successfully. | ||
| """ | ||
| FAILED | ||
| } | ||
|
|
||
| """ | ||
| Defines when the result() function should return, based on the status of the tasks. | ||
| """ | ||
| enum ReturnWhen { | ||
| FIRST_COMPLETED, # return the first task that completes or fails | ||
| ANY_COMPLETED, # return any task that completes or returns array of all the errors | ||
| ALL_COMPLETED, # return result of all the tasks or failures | ||
| """ | ||
| Return as soon as the first task completes or fails. | ||
| """ | ||
| FIRST_COMPLETED | ||
| """ | ||
| Return any task that completes or return an array of all the errors if tasks fail. | ||
| """ | ||
| ANY_COMPLETED | ||
| """ | ||
| Wait for all tasks to complete or fail and return the result. | ||
| """ | ||
| ALL_COMPLETED | ||
| } | ||
|
|
||
| type Task { | ||
| uri: String! | ||
| method: String! | ||
| args: Bytes! | ||
| """ | ||
| Indicates the priority level of a task. This helps determine the order in which tasks are executed. | ||
| """ | ||
| enum Priority { | ||
| """ | ||
| Low priority. Tasks with this priority will be executed after tasks with higher priority. | ||
| """ | ||
| LOW | ||
| """ | ||
| Medium priority. This is the default priority for tasks. | ||
| """ | ||
| MEDIUM | ||
| """ | ||
| High priority. Tasks with this priority will be executed before tasks with lower priority. | ||
| """ | ||
| HIGH | ||
| } | ||
|
|
||
| type TaskResult { | ||
| taskId: Int! | ||
| result: Bytes | ||
| error: String | ||
| status: TaskStatus! | ||
| """ | ||
| Defines the structure and parameters of a task. | ||
| """ | ||
| type Task { | ||
| """ | ||
| The URI of the wrapper to invoke. | ||
| """ | ||
| uri: String! | ||
| """ | ||
| The method to invoke. | ||
| """ | ||
| method: String! | ||
| """ | ||
| The arguments to be passed to the method upon invocation, serialized in MessagePack format. | ||
| """ | ||
| args: Bytes! | ||
| """ | ||
| The priority level of the task. This helps determine the order in which the task will be executed. Defaults to Priority.MEDIUM if not specified. | ||
| """ | ||
| priority: Priority | ||
| """ | ||
| A list of task IDs that the task depends on. The task will not be executed until all its dependencies have completed. | ||
| """ | ||
| dependsOn: [Int!] | ||
| """ | ||
| The maximum number of workers that should be used to execute this task. If not specified, the system will determine the optimal number of workers. | ||
| """ | ||
| max_workers: Int | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be beneficial to have |
||
| } | ||
|
|
||
| type Env { | ||
| max_workers: Int | ||
| """ | ||
| Defines the structure of the result returned by a task. | ||
| """ | ||
| type TaskResult { | ||
| """ | ||
| The unique ID assigned to the task. | ||
| """ | ||
| taskId: Int! | ||
| """ | ||
| The result produced by the task, serialized in MessagePack format. | ||
| """ | ||
| result: Bytes | ||
| """ | ||
| An error message, present only if the task failed to execute successfully. | ||
| """ | ||
| error: String | ||
| """ | ||
| The current status of the task. | ||
| """ | ||
| status: TaskStatus! | ||
| } | ||
|
|
||
| type Module { | ||
| result(taskIds: [Int!]!, returnWhen: ReturnWhen!): [TaskResult!]! | ||
| status(taskIds: [Int!]!): [TaskStatus!]! | ||
| schedule(tasks: [Task!]!): [Int!]! # returns taskIds | ||
| abort(taskIds: [String!]!): [Boolean!]! | ||
| """ | ||
| Retrieve the results of one or more scheduled tasks. The 'returnWhen' parameter determines when the function should return. | ||
| """ | ||
| result(taskIds: [Int!]!, returnWhen: ReturnWhen!): [TaskResult!]! | ||
|
|
||
| """ | ||
| Retrieve the current status of one or more scheduled tasks. | ||
| """ | ||
| status(taskIds: [Int!]!): [TaskStatus!]! | ||
|
|
||
| """ | ||
| Schedule one or more tasks for execution. Returns an array of unique task IDs, one for each scheduled task. | ||
| """ | ||
| schedule(tasks: [Task!]!): [Int!]! | ||
|
|
||
| """ | ||
| Send a request to abort one or more scheduled tasks. Returns an array of booleans indicating whether each task was successfully aborted. | ||
| """ | ||
| abort(taskIds: [Int!]!): [Boolean!]! | ||
|
|
||
| """ | ||
| Pause execution of one or more scheduled tasks. Returns an array of booleans indicating whether each task was successfully paused. | ||
| """ | ||
| pause(taskIds: [Int!]!): [Boolean!]! | ||
|
|
||
| """ | ||
| Resume execution of one or more paused tasks. Returns an array of booleans indicating whether each task was successfully resumed. | ||
| """ | ||
| resume(taskIds: [Int!]!): [Boolean!]! | ||
| } | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| format: 0.3.0 | ||
| project: | ||
| name: concurrent-interface | ||
| name: concurrency-interface | ||
| type: interface | ||
| source: | ||
| schema: ./polywrap.graphql | ||
| resources: ./resources |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1,98 @@ | ||
| # Concurrent Wrapper Interface | ||
| # Datetime Wrapper Interface | ||
|
|
||
| | Version | URI | WRAP Version | | ||
| |-|-|-| | ||
| | 1.0.0 | [`wrap://ens/wraps.eth:concurrent@1.0.0`](https://wrappers.io/v/ens/wraps.eth:concurrent@1.0.0) | 0.1 | | ||
|
|
||
| ## Description | ||
|
|
||
| The concurrent interface provides a common concurrency interface that can be shared across various concurrency implementations, like Threads, Processes and even language specific primitives like JavaScript Promises. | ||
| | 1.0.0 | [`wrap://ens/wraps.eth:concurrency@1.0.0`](https://wrappers.io/v/ens/wraps.eth:concurrency@1.0.0) | 0.1 | | ||
|
|
||
| ## Interface | ||
| ```graphql | ||
| enum TaskStatus { | ||
| PENDING # applicable when running in pool | ||
| RUNNING | ||
| COMPLETED | ||
| CANCELLED # applicable when threads/processes are used | ||
| FAILED | ||
| # Task is scheduled but not yet running. Applicable when running in pool | ||
| PENDING | ||
| # Task is executing | ||
| RUNNING | ||
| # Task is paused | ||
| SUSPENDED | ||
| # Task has completed execution | ||
| COMPLETED | ||
| # Task has been aborted. Applicable when threads/processes are used | ||
| CANCELLED | ||
| # Task failed to execute | ||
| FAILED | ||
| } | ||
|
|
||
| enum ReturnWhen { | ||
| FIRST_COMPLETED, # return the first task that completes or fails | ||
| ANY_COMPLETED, # return any task that completes or returns array of all the errors | ||
| ALL_COMPLETED, # return result of all the tasks or failures | ||
| # return the first task that completes or fails | ||
| FIRST_COMPLETED | ||
| # return any task that completes or returns array of all the errors | ||
| ANY_COMPLETED | ||
| # return result of all the tasks or failures | ||
| ALL_COMPLETED | ||
| } | ||
|
|
||
| type Task { | ||
| uri: String! | ||
| method: String! | ||
| args: Bytes! | ||
| # Priority helps determine the order in which tasks will be run | ||
| enum Priority { | ||
| LOW | ||
| MEDIUM | ||
| HIGH | ||
| } | ||
|
|
||
| type TaskResult { | ||
| taskId: Int! | ||
| result: Bytes | ||
| error: String | ||
| status: TaskStatus! | ||
| type Task { | ||
| # Wrap URI to invoke | ||
| uri: String! | ||
| # Method name | ||
| method: String! | ||
| # Invocation arguments, serialized in MessagePack format | ||
| args: Bytes! | ||
| # Priority helps determine the order in which tasks will be run. Defaults to Priority.MEDIUM. | ||
| priority: Priority | ||
| # Task will not run until dependent tasks have completed | ||
| dependsOn: [Int!] | ||
| # The maximum number of workers that should be used to execute this task | ||
| max_workers: Int | ||
| } | ||
|
|
||
| type Env { | ||
| max_workers: Int | ||
| type TaskResult { | ||
| # Unique ID of task | ||
| taskId: Int! | ||
| # Invocation result, serialized in MessagePack format | ||
| result: Bytes | ||
| # Error message that is present if task failed, and null otherwise | ||
| error: String | ||
| # The current status of the task | ||
| status: TaskStatus! | ||
| } | ||
|
|
||
| type Module { | ||
| result(taskIds: [Int!]!, returnWhen: ReturnWhen!): [TaskResult!]! | ||
| status(taskIds: [Int!]!): [TaskStatus!]! | ||
| schedule(tasks: [Task!]!): [Int!]! # returns taskIds | ||
| abort(taskIds: [String!]!): [Boolean!]! | ||
| # Get the result of one or more scheduled tasks | ||
| result(taskIds: [Int!]!, returnWhen: ReturnWhen!): [TaskResult!]! | ||
|
|
||
| # Get the status of one or more scheduled tasks | ||
| status(taskIds: [Int!]!): [TaskStatus!]! | ||
|
|
||
| # Schedule one or more tasks; returns the Task ID of each scheduled task | ||
| schedule(tasks: [Task!]!): [Int!]! | ||
|
|
||
| # Request to abort one or more scheduled tasks | ||
| abort(taskIds: [Int!]!): [Boolean!]! | ||
|
|
||
| # Pause execution of one or more scheduled tasks | ||
| pause(taskIds: [Int!]!): [Boolean!]! | ||
|
|
||
| # Resume execution of one or more paused tasks | ||
| resume(taskIds: [Int!]!): [Boolean!]! | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
| ```graphql | ||
| #import * from "ens/wraps.eth:concurrent@1.0.0" | ||
| #import * from "ens/wraps.eth:concurrency@1.0.0" | ||
| ``` | ||
|
|
||
| And implement the interface methods within your programming language of choice. | ||
|
|
||
| ## Source Code | ||
| [Link](https://github.com/polywrap/concurrent) | ||
| [Link](https://github.com/polywrap/std/concurrency) | ||
|
|
||
| ## Known Implementations | ||
| [Link](https://github.com/polywrap/concurrent/tree/main/implementations) | ||
| [Link](https://github.com/polywrap/concurrency/tree/master/implementations) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we enforce this? What are some use cases of this?