fork of indigo with slightly nicer lexgen

Re-export cache state lookup methods (#1110)

We still rely on knowing whether a lookup was a cache hit or not in some
of our services.

authored by bnewbold.net and committed by GitHub 5641d3c2 843b937d

Changed files
+10 -10
atproto
+5 -5
atproto/identity/cache_directory.go
··· 174 174 } 175 175 176 176 func (d *CacheDirectory) LookupDID(ctx context.Context, did syntax.DID) (*Identity, error) { 177 - id, _, err := d.lookupDIDWithCacheState(ctx, did) 177 + id, _, err := d.LookupDIDWithCacheState(ctx, did) 178 178 return id, err 179 179 } 180 180 181 - func (d *CacheDirectory) lookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*Identity, bool, error) { 181 + func (d *CacheDirectory) LookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*Identity, bool, error) { 182 182 start := time.Now() 183 183 entry, ok := d.identityCache.Get(did) 184 184 if ok && !d.isIdentityStale(&entry) { ··· 232 232 } 233 233 234 234 func (d *CacheDirectory) LookupHandle(ctx context.Context, h syntax.Handle) (*Identity, error) { 235 - ident, _, err := d.lookupHandleWithCacheState(ctx, h) 235 + ident, _, err := d.LookupHandleWithCacheState(ctx, h) 236 236 return ident, err 237 237 } 238 238 239 - func (d *CacheDirectory) lookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*Identity, bool, error) { 239 + func (d *CacheDirectory) LookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*Identity, bool, error) { 240 240 h = h.Normalize() 241 241 did, err := d.ResolveHandle(ctx, h) 242 242 if err != nil { 243 243 return nil, false, err 244 244 } 245 - ident, hit, err := d.lookupDIDWithCacheState(ctx, did) 245 + ident, hit, err := d.LookupDIDWithCacheState(ctx, did) 246 246 if err != nil { 247 247 return nil, hit, err 248 248 }
+5 -5
atproto/identity/redisdir/redis_directory.go
··· 273 273 } 274 274 275 275 func (d *RedisDirectory) LookupDID(ctx context.Context, did syntax.DID) (*identity.Identity, error) { 276 - id, _, err := d.lookupDIDWithCacheState(ctx, did) 276 + id, _, err := d.LookupDIDWithCacheState(ctx, did) 277 277 return id, err 278 278 } 279 279 280 - func (d *RedisDirectory) lookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*identity.Identity, bool, error) { 280 + func (d *RedisDirectory) LookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*identity.Identity, bool, error) { 281 281 start := time.Now() 282 282 var entry identityEntry 283 283 err := d.identityCache.Get(ctx, redisDirPrefix+did.String(), &entry) ··· 340 340 } 341 341 342 342 func (d *RedisDirectory) LookupHandle(ctx context.Context, h syntax.Handle) (*identity.Identity, error) { 343 - ident, _, err := d.lookupHandleWithCacheState(ctx, h) 343 + ident, _, err := d.LookupHandleWithCacheState(ctx, h) 344 344 return ident, err 345 345 } 346 346 347 - func (d *RedisDirectory) lookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*identity.Identity, bool, error) { 347 + func (d *RedisDirectory) LookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*identity.Identity, bool, error) { 348 348 h = h.Normalize() 349 349 did, err := d.ResolveHandle(ctx, h) 350 350 if err != nil { 351 351 return nil, false, err 352 352 } 353 - ident, hit, err := d.lookupDIDWithCacheState(ctx, did) 353 + ident, hit, err := d.LookupDIDWithCacheState(ctx, did) 354 354 if err != nil { 355 355 return nil, hit, err 356 356 }