Skip to content

Commit

Permalink
feat: group workflow limits on a top-level field
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Feb 10, 2025
1 parent 8a03a29 commit 5dd51d6
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 15 deletions.
2 changes: 2 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ MaxBinarySize = '20.00mb' # Default
MaxEncryptedSecretsSize = '26.40kb' # Default
# MaxConfigSize is the maximum size of a config that can be fetched from the given config url.
MaxConfigSize = '50.00kb' # Default

[Capabilities.WorkflowRegistry.Limits]
# WorkflowsGlobalLimit is the maximum number of workflows that can be registered globally.
WorkflowsGlobalLimit = 50 # Default
# WorkflowsPerOwnerLimit is the maximum number of workflows that can be registered per owner.
Expand Down
26 changes: 17 additions & 9 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1487,15 +1487,29 @@ func (r *ExternalRegistry) setFrom(f *ExternalRegistry) {
}
}

type WorkflowLimits struct {
WorkflowsGlobalLimit *int32
WorkflowsPerOwnerLimit *int32
}

func (r *WorkflowLimits) setFrom(f *WorkflowLimits) {
if f.WorkflowsGlobalLimit != nil {
r.WorkflowsGlobalLimit = f.WorkflowsGlobalLimit
}

if f.WorkflowsPerOwnerLimit != nil {
r.WorkflowsPerOwnerLimit = f.WorkflowsPerOwnerLimit
}
}

type WorkflowRegistry struct {
Address *string
NetworkID *string
ChainID *string
MaxBinarySize *utils.FileSize
MaxEncryptedSecretsSize *utils.FileSize
MaxConfigSize *utils.FileSize
WorkflowsGlobalLimit *int32
WorkflowsPerOwnerLimit *int32
Limits WorkflowLimits
}

func (r *WorkflowRegistry) setFrom(f *WorkflowRegistry) {
Expand Down Expand Up @@ -1523,13 +1537,7 @@ func (r *WorkflowRegistry) setFrom(f *WorkflowRegistry) {
r.MaxConfigSize = f.MaxConfigSize
}

if f.WorkflowsGlobalLimit != nil {
r.WorkflowsGlobalLimit = f.WorkflowsGlobalLimit
}

if f.WorkflowsPerOwnerLimit != nil {
r.WorkflowsPerOwnerLimit = f.WorkflowsPerOwnerLimit
}
r.Limits.setFrom(&f.Limits)
}

type Dispatcher struct {
Expand Down
4 changes: 2 additions & 2 deletions core/services/chainlink/config_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ func (c *capabilitiesWorkflowRegistry) MaxConfigSize() utils.FileSize {
}

func (c *capabilitiesWorkflowRegistry) WorkflowsGlobalLimit() int32 {
return *c.c.WorkflowsGlobalLimit
return *c.c.Limits.WorkflowsGlobalLimit
}

func (c *capabilitiesWorkflowRegistry) WorkflowsPerOwnerLimit() int32 {
return *c.c.WorkflowsPerOwnerLimit
return *c.c.Limits.WorkflowsPerOwnerLimit
}

type gatewayConnector struct {
Expand Down
6 changes: 4 additions & 2 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,10 @@ func TestConfig_Marshal(t *testing.T) {
MaxBinarySize: ptr(utils.FileSize(20 * utils.MB)),
MaxEncryptedSecretsSize: ptr(utils.FileSize(26.4 * utils.KB)),
MaxConfigSize: ptr(utils.FileSize(50 * utils.KB)),
WorkflowsGlobalLimit: ptr(int32(50)),
WorkflowsPerOwnerLimit: ptr(int32(5)),
Limits: toml.WorkflowLimits{
WorkflowsGlobalLimit: ptr(int32(50)),
WorkflowsPerOwnerLimit: ptr(int32(5)),
},
},
Dispatcher: toml.Dispatcher{
SupportedVersion: ptr(1),
Expand Down
2 changes: 2 additions & 0 deletions core/services/chainlink/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ ChainID = '1'
MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

Expand Down
2 changes: 2 additions & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ ChainID = '1'
MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ ChainID = '1'
MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

Expand Down
10 changes: 8 additions & 2 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,6 @@ ChainID = '1' # Default
MaxBinarySize = '20.00mb' # Default
MaxEncryptedSecretsSize = '26.40kb' # Default
MaxConfigSize = '50.00kb' # Default
WorkflowsGlobalLimit = 50 # Default
WorkflowsPerOwnerLimit = 5 # Default
```


Expand Down Expand Up @@ -1304,6 +1302,14 @@ MaxConfigSize = '50.00kb' # Default
```
MaxConfigSize is the maximum size of a config that can be fetched from the given config url.

## Capabilities.WorkflowRegistry.Limits
```toml
[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50 # Default
WorkflowsPerOwnerLimit = 5 # Default
```


### WorkflowsGlobalLimit
```toml
WorkflowsGlobalLimit = 50 # Default
Expand Down

0 comments on commit 5dd51d6

Please sign in to comment.