-
Notifications
You must be signed in to change notification settings - Fork 0
[CLD-354]: feat(operation): support execution of dynamic operation #174
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
Conversation
🦋 Changeset detectedLatest commit: f23f6b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
1f3e1eb
to
8371a5a
Compare
8371a5a
to
1e4b1c1
Compare
To enhance the flexibility of Operations API, we want to support dynamic execution of Operation. Imagine this snippet of code: ``` inputs := []any{"input1", 42} deps := []any{Deps1{}, Deps2{}} defs := []Definition{ {ID: "string-op", Version: semver.MustParse("1.0.0")}, {ID: "int-op", Version: semver.MustParse("1.0.0")}, } // dynamically retrieve and execute operations on different inputs for i, def := range defs { // registry contains a list of operations retrievedOp, _ := registry.Retrieve(def) // dependency and input are dynamic/different per Operation report, _ := ExecuteOperation(b, retrievedOp, deps[i], inputs[i]) } ``` Based on the definition, we can decide on run time what operations to execute and what input and deps to pass in to that operation. This can be quite powerful to allow users to dynamically construct a series of operation under a sequence. JIRA: https://smartcontract-it.atlassian.net/browse/CLD-354
1e4b1c1
to
ec99ee5
Compare
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.
Thanks @graham-chainlink ! LGTM :)
operations/registry_test.go
Outdated
}, | ||
) | ||
// Create registry with untyped operations | ||
registry := NewOperationRegistry(stringOp.AsUntyped(), intOp.AsUntyped()) |
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.
This is more of a question.
Could NewOperationRegistry
call AsUntyped()
to any provided inputs? Then the user doesn't have to remember doing that for every input 🤔
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.
Could NewOperationRegistry call AsUntyped() to any provided inputs?
haha well for NewOperationRegistry
to accept any input in the first place, we have to call AsUntyped
to convert it into any type.
so we cant do
r := NewOperationRegistry(stringOp, intOp)
// then call untype inside
because the parameter NewOperationRegistry
has to be any
type in order to accept any operations as each operation has different types for input, output if that make sense
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.
alright added a helper
// Create registry with untyped operations by providing optional initial operation
registry := NewOperationRegistry(stringOp.AsUntyped())
// An alternative way to register additional operations without calling AsUntyped()
RegisterOperation(registry, intOp)
f23f6b6
|
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## chainlink-deployments-framework@0.13.0 ### Minor Changes - [#174](#174) [`4a4f9b2`](4a4f9b2) Thanks [@graham-chainlink](https://github.com/graham-chainlink)! - feat: support dynamic execution of operation - [#166](#166) [`f5a2ca9`](f5a2ca9) Thanks [@jkongie](https://github.com/jkongie)! - Adds a zkSync CTF provider under the EVM Chain --------- Co-authored-by: app-token-issuer-engops[bot] <144731339+app-token-issuer-engops[bot]@users.noreply.github.com>
To enhance the flexibility of Operations API, we want to support dynamic execution of Operation.
Based on the operation definition, we can decide on run time what operations to execute and what input and deps to pass in to that operation. This can be quite powerful to allow users to dynamically construct a series of operation under a sequence.
Refer to this example code snippet:
JIRA: https://smartcontract-it.atlassian.net/browse/CLD-354