Conversation
Delegated targets should be loaded at target search time, so keep state in memory so we can use it as necessary. Signed-off-by: Appu Goundan <appu@google.com>
| } | ||
|
|
||
| public void setRoot(Root root) throws IOException { | ||
| // call storeTrustedRoot instead of generic storeMeta because it does doesn't extra work |
| } | ||
|
|
||
| public Root getRoot() throws IOException { | ||
| return findRoot().orElseThrow(() -> new IllegalStateException("No cached root to load")); |
There was a problem hiding this comment.
maybe you can provide a little more context here (in the exception message) as to why this would happen?
There was a problem hiding this comment.
I think you really only call "getRoot" if you know you should have a root cached somewhere. But I guess I can add context.
There was a problem hiding this comment.
I guess from the point of the view of the user, if this blows up, what most likely happened, how can they fix it?
| return Optional.ofNullable(root); | ||
| } | ||
|
|
||
| public void setTimestamp(Timestamp timestamp) throws IOException { |
There was a problem hiding this comment.
not tempted to factor out the set/find/get logic?
There was a problem hiding this comment.
I was tempted but it meant generifying some of the getters and setters. I can do that
| this.localStore = localStore; | ||
| this.metaFetcher = metaFetcher; | ||
| this.targetFetcher = targetFetcher; | ||
| this.trustedMeta = TrustedMeta.newTrustedMeta(localStore); |
There was a problem hiding this comment.
since it's a read-through cache, could it be simpler to just invalidate it on update or something rather than having the updater have to know about it?
There was a problem hiding this comment.
Oh like if the root updated?
|
alright, reworked this whole thing |
| /** | ||
| * Generic method to store one of the {@link SignedTufMeta} resources in the local tuf store. | ||
| * Generic method to store one of the {@link SignedTufMeta} resources in the local tuf store. Do | ||
| * not use for Root role, use {@link #setRoot(Root)} instead. |
There was a problem hiding this comment.
what happens if you do use it for Root?
There was a problem hiding this comment.
then you don't get N.root persisted (this is functionality that was already in there). I've just formalized it.
sigstore-java/src/main/java/dev/sigstore/tuf/PassthroughCacheMetaStore.java
Outdated
Show resolved
Hide resolved
| /** An in memory cache that will pass through to a provided local tuf store. */ | ||
| public class PassthroughCacheMetaStore implements MetaReader, MetaStore { | ||
| private final MetaStore localStore; | ||
| private final Map<String, SignedTufMeta<? extends TufMeta>> cache; |
There was a problem hiding this comment.
I think Guava has a Cache you can pass a read-through function to 🤔. I'm way out of date though so don't hesitate to tell me to GTFO
There was a problem hiding this comment.
Yeah it's a bit heavyweight, has eviction and what not. This is not a space limited cache.
888afee to
4c741ca
Compare
4c741ca to
33482eb
Compare
Delegated targets should be loaded at target search time, so keep state in memory so we can use it as necessary.
This PR doesn't does add delegated targets support, but this is part of the process.