feat(datafile-cache): Add support for datafile cache service.#340
feat(datafile-cache): Add support for datafile cache service.#340msohailhussain wants to merge 4 commits intomasterfrom
Conversation
| datafileURLTemplate: "https://localhost/v1/%s.json" | ||
| eventURL: "https://logx.localhost.com/v1" | ||
| sdkKeyRegex: "custom-regex" | ||
| datafileCacheService: |
There was a problem hiding this comment.
datafileCacheServices will be more relevant.
There was a problem hiding this comment.
This is to keep it similar to the naming convention we are following for userProfileService.
| datafileURLTemplate: "https://localhost/v1/%s.json" | ||
| eventURL: "https://logx.localhost.com/v1" | ||
| sdkKeyRegex: "custom-regex" | ||
| datafileCacheService: |
There was a problem hiding this comment.
add one more property enableDatafileCacheService and based on that, execute the logic.
| options := []sdkconfig.OptionFunc{} | ||
|
|
||
| // Check if datafile is already present in cache | ||
| cachedDatafile, cacheService := getDatafileFromCacheService(ctx, sdkKey, conf) |
There was a problem hiding this comment.
add a condition of cache is enabled then go into this method.
|
|
||
| var clientUserProfileService decision.UserProfileService | ||
| if clientUserProfileService = getUserProfileService(sdkKey, userProfileServiceMap, conf); clientUserProfileService != nil { | ||
| if clientUserProfileService = getUserProfileService(ctx, sdkKey, userProfileServiceMap, conf); clientUserProfileService != nil { |
There was a problem hiding this comment.
Why we need to change this method.
There was a problem hiding this comment.
Earlier, We were giving UPS a different context altogether which might've resulted in UPS requests still running for a little while after agent had shut down. This fix is to pass the original agent context to UPS so that once agents shuts down, UPS terminates all its requests as well.
| } | ||
|
|
||
| // RedisCacheService represents the redis implementation of DatafileCacheService interface | ||
| type RedisCacheService struct { |
There was a problem hiding this comment.
this struct is same for UPS as well, can't we use the same.
Summary
Tests
Redis Datafile Cache Service
To enable redis datafile cache service, Update the
config.yamlfile with yourdatafileCacheServiceconfig as shown below: