Skip to content
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

Fix DB event issue #2614

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions common-controller/internal/database/db_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (dbDeployer DBDeployer) DeployApplication(application server.Application) e
return deployApplicationwithAttributes(tx, application)
})
server.AddApplication(application)
utils.SendApplicationEvent(constants.ApplicationCreated, application.UUID, application.Name, application.Owner,
application.OrganizationID, application.Attributes)
return nil
}

Expand All @@ -103,6 +105,8 @@ func (dbDeployer DBDeployer) UpdateApplication(application server.Application) e
})
server.DeleteApplication(application.UUID)
server.AddApplication(application)
utils.SendApplicationEvent(constants.ApplicationUpdated, application.UUID, application.Name, application.Owner,
application.OrganizationID, application.Attributes)
return nil
}

Expand All @@ -114,6 +118,8 @@ func (dbDeployer DBDeployer) DeploySubscription(subscription server.Subscription
subscription.SubStatus, subscription.Organization, subscription.RatelimitTier)
})
server.AddSubscription(subscription)
utils.SendSubscriptionEvent(constants.SubscriptionCreated, subscription.UUID, subscription.SubStatus, subscription.Organization,
subscription.SubscribedAPI.Name, subscription.SubscribedAPI.Version, subscription.RatelimitTier)
return nil
}

Expand All @@ -126,6 +132,8 @@ func (dbDeployer DBDeployer) UpdateSubscription(subscription server.Subscription
})
server.DeleteSubscription(subscription.UUID)
server.AddSubscription(subscription)
utils.SendSubscriptionEvent(constants.SubscriptionUpdated, subscription.UUID, subscription.SubStatus, subscription.Organization,
subscription.SubscribedAPI.Name, subscription.SubscribedAPI.Version, subscription.RatelimitTier)
return nil
}

Expand All @@ -137,6 +145,8 @@ func (dbDeployer DBDeployer) DeployApplicationMappings(applicationMapping server
applicationMapping.OrganizationID)
})
server.AddApplicationMapping(applicationMapping)
utils.SendApplicationMappingEvent(constants.ApplicationMappingCreated, applicationMapping.UUID, applicationMapping.ApplicationRef,
applicationMapping.SubscriptionRef, applicationMapping.OrganizationID)
return nil
}

Expand All @@ -155,6 +165,8 @@ func (dbDeployer DBDeployer) DeployKeyMappings(keyMapping server.ApplicationKeyM
})

server.AddApplicationKeyMapping(keyMapping)
utils.SendApplicationKeyMappingEvent(constants.ApplicationKeyMappingCreated, keyMapping.ApplicationUUID, keyMapping.SecurityScheme,
keyMapping.ApplicationIdentifier, keyMapping.KeyType, keyMapping.EnvID, keyMapping.OrganizationID)
return nil
}

Expand Down Expand Up @@ -184,6 +196,7 @@ func (dbDeployer DBDeployer) DeleteApplication(applicationID string) error {
return DeleteApplicationAttributes(tx, applicationID)
})
server.DeleteApplication(applicationID)
utils.SendApplicationEvent(constants.ApplicationDeleted, applicationID, "", "", "", nil)
return nil
}

Expand All @@ -194,6 +207,7 @@ func (dbDeployer DBDeployer) DeleteApplicationMappings(applicationMapping string
return DeleteAppSub(tx, applicationMapping)
})
server.DeleteApplicationMapping(applicationMapping)
utils.SendApplicationMappingEvent(constants.ApplicationMappingDeleted, applicationMapping, "", "", "")
return nil
}

Expand All @@ -206,6 +220,8 @@ func (dbDeployer DBDeployer) UpdateApplicationMappings(applicationMapping server
})
server.DeleteApplicationMapping(applicationMapping.UUID)
server.AddApplicationMapping(applicationMapping)
utils.SendApplicationMappingEvent(constants.ApplicationMappingUpdated, applicationMapping.UUID, applicationMapping.ApplicationRef,
applicationMapping.SubscriptionRef, applicationMapping.OrganizationID)
return nil
}

Expand All @@ -216,6 +232,8 @@ func (dbDeployer DBDeployer) DeleteKeyMappings(keyMapping server.ApplicationKeyM
return DeleteApplicationKeyMapping(tx, keyMapping.ApplicationUUID, keyMapping.SecurityScheme, keyMapping.EnvID)
})
server.DeleteApplicationKeyMapping(keyMapping)
utils.SendApplicationKeyMappingEvent(constants.ApplicationKeyMappingDeleted, keyMapping.ApplicationUUID, keyMapping.SecurityScheme,
keyMapping.ApplicationIdentifier, keyMapping.KeyType, keyMapping.EnvID, keyMapping.OrganizationID)
return nil
}

Expand All @@ -226,6 +244,7 @@ func (dbDeployer DBDeployer) DeleteSubscription(subscriptionID string) error {
return DeleteSubscription(tx, subscriptionID)
})
server.DeleteSubscription(subscriptionID)
utils.SendSubscriptionEvent(constants.SubscriptionDeleted, subscriptionID, "", "", "", "", "")
return nil
}

Expand Down Expand Up @@ -299,6 +318,8 @@ func (dbDeployer DBDeployer) UpdateKeyMappings(keyMapping server.ApplicationKeyM

server.DeleteApplicationKeyMapping(keyMapping)
server.AddApplicationKeyMapping(keyMapping)
utils.SendApplicationKeyMappingEvent(constants.ApplicationKeyMappingUpdated, keyMapping.ApplicationUUID, keyMapping.SecurityScheme,
keyMapping.ApplicationIdentifier, keyMapping.KeyType, keyMapping.EnvID, keyMapping.OrganizationID)
return nil
}

Expand Down
Loading