[BEAM-13632][Playground] Save catalog data to the cache#16493
[BEAM-13632][Playground] Save catalog data to the cache#16493pabloem merged 9 commits intoapache:masterfrom
Conversation
playground/backend/internal/utils/precompiled_objects_utils_test.go
Outdated
Show resolved
Hide resolved
AydarZaynutdinov
left a comment
There was a problem hiding this comment.
Overall LGTM. Last minor suggestion.
| } else { | ||
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) | ||
| } |
There was a problem hiding this comment.
| } else { | |
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) | |
| } | |
| } | |
| logger.Errorf("GetPrecompiledObjects(): cache error: %s", err.Error()) |
There was a problem hiding this comment.
Good idea, thanks!
| func (controller *playgroundController) GetPrecompiledObjects(ctx context.Context, info *pb.GetPrecompiledObjectsRequest) (*pb.GetPrecompiledObjectsResponse, error) { | ||
| bucket := cloud_bucket.New() | ||
| sdkToCategories, err := bucket.GetPrecompiledObjects(ctx, info.Sdk, info.Category) | ||
| if info.Sdk == pb.Sdk_SDK_UNSPECIFIED && info.Category == "" { |
There was a problem hiding this comment.
why we need this if here?
There was a problem hiding this comment.
Changed per our discussion
| LogsIndex SubKey = "LOGS_INDEX" | ||
|
|
||
| // ExamplesCatalog is catalog of examples available in Playground | ||
| ExamplesCatalog SubKey = "EXAMPLES_CATALOG" |
There was a problem hiding this comment.
Instead of make workarounds with subkey without pipeline id. Can we extend the Cache interface and implementation with SetCatalog, GetKatalog?
There was a problem hiding this comment.
You are right, changed
| } | ||
|
|
||
| // GetPrecompiledObjectsCatalogFromCache returns the precompiled objects catalog from the cache | ||
| func GetPrecompiledObjectsCatalogFromCache(ctx context.Context, cacheService cache.Cache) ([]*pb.Categories, error) { |
There was a problem hiding this comment.
can we make this name shorter?
GetPrecompiledObjectsFromCache
There was a problem hiding this comment.
This one became redundant and GetPrecompiledObjectsCatalogFromStorage I changed to GetCatalogFromStorage
d93dc2b to
7fe3d8b
Compare
| // SetCatalog adds the given catalog to cache by ExamplesCatalog key. | ||
| SetCatalog(ctx context.Context, catalog []*pb.Categories) error | ||
|
|
||
| // GetCatalog return catalog from cache by ExamplesCatalog key. | ||
| GetCatalog(ctx context.Context) ([]*pb.Categories, error) |
There was a problem hiding this comment.
Why can't we use already existing methods GetValue and SetValue? Is it because we use Get/Set for catalog instead of HGet/HSet?
There was a problem hiding this comment.
Yes, we save it without the workaround with nil pipelined as It was before.
| // - If SDK and category are unspecified in the request, gets the whole catalog from the cache | ||
| // - If there is no catalog in the cache, gets the catalog from the Storage and saves it to the cache | ||
| // - If SDK or category is specified in the request, gets the specific catalog from the Storage |
There was a problem hiding this comment.
It seems that the comment here doesn't match the method logic. The method gets a catalog from the cache in all cases, not only if SDK and category are unspecified
There was a problem hiding this comment.
Thanks for noticing, changed!
| } | ||
|
|
||
| // GetCatalogFromStorage returns the precompiled objects catalog from the cloud storage | ||
| func GetCatalogFromStorage(ctx context.Context) ([]*pb.Categories, error) { |
There was a problem hiding this comment.
Is it possible to add tests for this method?
There was a problem hiding this comment.
No, its logic is connected with retrieving the data from the bucket – testing this will be integration testing, which we don't do now.
# Conflicts: # playground/backend/internal/cache/cache.go
|
R: @pabloem |
|
this looks fine to me. thanks! |
BEAM-13632 The catalog is now saved into the cache at the server startup.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunnercompliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.