mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
This feature adds the capability to stop unregistered running instances upon startup. Previously, you had to stop running instances manually or issue an initial request that will shut down instances afterwards. With this change, all discovered instances will be shutdown. They need to be registered using labels. E.g.: sablier.enable=true Fixes #153
22 lines
732 B
Go
22 lines
732 B
Go
package arrays
|
|
|
|
// RemoveElements returns a new slice containing all elements from `allElements` that are not in `elementsToRemove`
|
|
func RemoveElements(allElements, elementsToRemove []string) []string {
|
|
// Create a map to store elements to remove for quick lookup
|
|
removeMap := make(map[string]struct{}, len(elementsToRemove))
|
|
for _, elem := range elementsToRemove {
|
|
removeMap[elem] = struct{}{}
|
|
}
|
|
|
|
// Create a slice to store the result
|
|
result := make([]string, 0, len(allElements)) // Preallocate memory based on the size of allElements
|
|
for _, elem := range allElements {
|
|
// Check if the element is not in the removeMap
|
|
if _, found := removeMap[elem]; !found {
|
|
result = append(result, elem)
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|