You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User Story
As a developer, I want providers to be immediately removed from the queue when their node is turned off, so that the system does not route orders to unavailable providers.
Acceptance Criteria
GIVEN a provider's IsAvailable status is set to false WHEN the provider profile is updated THEN the provider should be removed from all relevant Redis queues.
GIVEN a provider is removed from the queue WHEN the Redis operation fails THEN an error should be logged, and the provider profile update should still proceed.
Tech Details
Modify the UpdateProviderProfile function to:
Check if IsAvailable is being set to false.
If IsAvailable is set to false, search for and remove the provider from all relevant Redis queues.
Use the provided Redis logic to:
Search for the provider in the queue using LIndex.
Replace the provider's entry with a placeholder (DELETED_PROVIDER).
Remove all occurrences of the placeholder using LRem.
Ensure the Redis operations are atomic and do not block the provider profile update.
Example removal from redis:
// Remove provider from Redis queuesredisKey:=fmt.Sprintf("bucket_%s_%s_%s", provider.Edges.Currency.Code, provider.Edges.ProvisionBucket.MinAmount, provider.Edges.ProvisionBucket.MaxAmount)
forindex:=-1; ; index-- {
providerData, err:=storage.RedisClient.LIndex(ctx, redisKey, int64(index)).Result()
iferr!=nil {
break
}
parts:=strings.Split(providerData, ":")
iflen(parts) !=5 {
logger.Errorf("invalid provider data format: %s", providerData)
continue
}
ifparts[0] ==provider.ID {
placeholder:="DELETED_PROVIDER"_, err:=storage.RedisClient.LSet(ctx, redisKey, int64(index), placeholder).Result()
iferr!=nil {
logger.Errorf("failed to set placeholder at index %d: %v", index, err)
}
_, err=storage.RedisClient.LRem(ctx, redisKey, 0, placeholder).Result()
iferr!=nil {
logger.Errorf("failed to remove placeholder from circular queue: %v", err)
}
break
}
}
Notes/Assumptions
The Redis queue key format is bucket_<currency>_<minAmount>_<maxAmount>.
The provider data in Redis is stored in the format providerID:token:rate:minAmount:maxAmount.
The feature should handle cases where the provider is not found in the queue.
Open Questions
Should we notify the provider when they are removed from the queue due to unavailability?
The text was updated successfully, but these errors were encountered:
Yes, providers should be notified when they are removed from the queue due to unavailability.
This notification system would serve multiple important purposes:
Providers can quickly identify why they're not receiving orders
Enables faster troubleshooting of availability issues
User Story
As a developer, I want providers to be immediately removed from the queue when their node is turned off, so that the system does not route orders to unavailable providers.
Acceptance Criteria
GIVEN a provider's
IsAvailable
status is set tofalse
WHEN the provider profile is updated
THEN the provider should be removed from all relevant Redis queues.
GIVEN a provider is removed from the queue
WHEN the Redis operation fails
THEN an error should be logged, and the provider profile update should still proceed.
Tech Details
Modify the
UpdateProviderProfile
function to:IsAvailable
is being set tofalse
.IsAvailable
is set tofalse
, search for and remove the provider from all relevant Redis queues.Use the provided Redis logic to:
LIndex
.DELETED_PROVIDER
).LRem
.Ensure the Redis operations are atomic and do not block the provider profile update.
Example removal from redis:
Notes/Assumptions
bucket_<currency>_<minAmount>_<maxAmount>
.providerID:token:rate:minAmount:maxAmount
.Open Questions
The text was updated successfully, but these errors were encountered: