Skip to content

Commit

Permalink
fix: check capability type
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Nov 11, 2024
1 parent 422e385 commit 6535231
Show file tree
Hide file tree
Showing 2 changed files with 343 additions and 114 deletions.
14 changes: 12 additions & 2 deletions core/capabilities/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,14 @@ func (w *launcher) exposeCapabilities(ctx context.Context, myPeerID p2ptypes.Pee
switch capability.CapabilityType {
case capabilities.CapabilityTypeTrigger:
newTriggerPublisher := func(cap capabilities.BaseCapability, info capabilities.CapabilityInfo) (remotetypes.ReceiverService, error) {
triggerCapability, ok := (cap).(capabilities.TriggerCapability)
if !ok {
return nil, fmt.Errorf("capability does not implement TriggerCapability")

Check failure on line 401 in core/capabilities/launcher.go

View workflow job for this annotation

GitHub Actions / lint

fmt.Errorf can be replaced with errors.New (perfsprint)
}

publisher := remote.NewTriggerPublisher(
capabilityConfig.RemoteTriggerConfig,
cap.(capabilities.TriggerCapability),
triggerCapability,
info,
don.DON,
idsToDONs,
Expand All @@ -419,10 +424,15 @@ func (w *launcher) exposeCapabilities(ctx context.Context, myPeerID p2ptypes.Pee
w.lggr.Warn("no remote client configured for capability type consensus, skipping configuration")
case capabilities.CapabilityTypeTarget:
newTargetServer := func(cap capabilities.BaseCapability, info capabilities.CapabilityInfo) (remotetypes.ReceiverService, error) {
targetCapability, ok := (cap).(capabilities.TargetCapability)
if !ok {
return nil, fmt.Errorf("capability does not implement TargetCapability")

Check failure on line 429 in core/capabilities/launcher.go

View workflow job for this annotation

GitHub Actions / lint

fmt.Errorf can be replaced with errors.New (perfsprint)
}

return target.NewServer(
capabilityConfig.RemoteTargetConfig,
myPeerID,
cap.(capabilities.TargetCapability),
targetCapability,
info,
don.DON,
idsToDONs,
Expand Down
Loading

0 comments on commit 6535231

Please sign in to comment.