A container registry that uses the AT Protocol for manifest storage and S3 for blob storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

need the actually new file

+58
+58
pkg/atproto/directory.go
··· 1 + package atproto 2 + 3 + import ( 4 + "context" 5 + "net" 6 + "net/http" 7 + "sync" 8 + "time" 9 + 10 + "github.com/bluesky-social/indigo/atproto/identity" 11 + "github.com/earthboundkid/versioninfo/v2" 12 + ) 13 + 14 + var ( 15 + // Shared identity directory instance (singleton) 16 + sharedDirectory identity.Directory 17 + directoryOnce sync.Once 18 + ) 19 + 20 + // GetDirectory returns a shared identity.Directory instance with an 8-hour cache TTL. 21 + // This is based on indigo's DefaultDirectory() but with a reduced cache TTL 22 + // to allow faster recovery from PDS migrations (8h instead of 24h). 23 + // 24 + // Using a shared instance ensures all identity lookups across the application 25 + // use the same cache, which is more memory-efficient and provides better cache hit rates. 26 + func GetDirectory() identity.Directory { 27 + directoryOnce.Do(func() { 28 + base := identity.BaseDirectory{ 29 + PLCURL: identity.DefaultPLCURL, 30 + HTTPClient: http.Client{ 31 + Timeout: time.Second * 10, 32 + Transport: &http.Transport{ 33 + // would want this around 100ms for services doing lots of handle resolution. Impacts PLC connections as well, but not too bad. 34 + IdleConnTimeout: time.Millisecond * 1000, 35 + MaxIdleConns: 100, 36 + }, 37 + }, 38 + Resolver: net.Resolver{ 39 + Dial: func(ctx context.Context, network, address string) (net.Conn, error) { 40 + d := net.Dialer{Timeout: time.Second * 3} 41 + return d.DialContext(ctx, network, address) 42 + }, 43 + }, 44 + TryAuthoritativeDNS: true, 45 + // primary Bluesky PDS instance only supports HTTP resolution method 46 + SkipDNSDomainSuffixes: []string{".bsky.social"}, 47 + UserAgent: "indigo-identity/" + versioninfo.Short(), 48 + } 49 + // Cache configuration: 50 + // - capacity: 250,000 entries 51 + // - hitTTL: 8 hours (reduced from indigo's default 24h for faster PDS migration recovery) 52 + // - errTTL: 2 minutes 53 + // - invalidHandleTTL: 5 minutes 54 + cached := identity.NewCacheDirectory(&base, 250_000, time.Hour*8, time.Minute*2, time.Minute*5) 55 + sharedDirectory = &cached 56 + }) 57 + return sharedDirectory 58 + }