···4343 // pieces that abstract the need for explicit ssl checks
4444 ssl bool
45454646- crawlOnly bool
4747-4846 // TODO: at some point we will want to lock specific DIDs, this lock as is
4947 // is overly broad, but i dont expect it to be a bottleneck for now
5048 extUserLk sync.Mutex
···7573 ConcurrencyPerPDS int64
7674 MaxQueuePerPDS int64
7775 NumCompactionWorkers int
7878-7979- // NextCrawlers gets forwarded POST /xrpc/com.atproto.sync.requestCrawl
8080- NextCrawlers []*url.URL
8176}
82778378func DefaultArchiverConfig() *ArchiverConfig {
···153148154149type User struct {
155150 gorm.Model
156156- ID models.Uid `gorm:"primarykey;index:idx_user_id_active,where:taken_down = false AND tombstoned = false"`
151151+ ID models.Uid `gorm:"primarykey"`
157152 Did string `gorm:"uniqueindex"`
158153 PDS uint
159154···201196 durl.Scheme = "http"
202197 }
203198204204- // TODO: the PDS's DID should also be in the service, we could use that to look up?
205199 var peering models.PDS
206200 if err := s.db.Find(&peering, "host = ?", durl.Host).Error; err != nil {
207201 s.log.Error("failed to find pds", "host", durl.Host)
···268262 s.extUserLk.Lock()
269263 defer s.extUserLk.Unlock()
270264271271- exu, err := s.LookupUserByDid(ctx, did)
265265+ exu, err := s.lookupUserByDid(ctx, did)
272266 if err == nil {
273267 s.log.Debug("lost the race to create a new user", "did", did)
274268 if exu.PDS != peering.ID {
···561555 }
562556563557 s.userCache.Add(did, &u)
564564-565565- return &u, nil
566566-}
567567-568568-func (s *Archiver) lookupUserByUID(ctx context.Context, uid models.Uid) (*User, error) {
569569- ctx, span := tracer.Start(ctx, "lookupUserByUID")
570570- defer span.End()
571571-572572- var u User
573573- if err := s.db.Find(&u, "id = ?", uid).Error; err != nil {
574574- return nil, err
575575- }
576576-577577- if u.ID == 0 {
578578- return nil, gorm.ErrRecordNotFound
579579- }
580558581559 return &u, nil
582560}
+1-14
archiver/loader.go
···1515 ctx, span := otel.Tracer("indexer").Start(ctx, "getUserOrMissing")
1616 defer span.End()
17171818- ai, err := s.LookupUserByDid(ctx, did)
1818+ ai, err := s.lookupUserByDid(ctx, did)
1919 if err == nil {
2020 return ai, nil
2121 }
···6868 var ai User
6969 if err := s.db.First(&ai, "id = ?", id).Error; err != nil {
7070 return nil, err
7171- }
7272-7373- return &ai, nil
7474-}
7575-7676-func (s *Archiver) LookupUserByDid(ctx context.Context, did string) (*User, error) {
7777- var ai User
7878- if err := s.db.Find(&ai, "did = ?", did).Error; err != nil {
7979- return nil, err
8080- }
8181-8282- if ai.ID == 0 {
8383- return nil, gorm.ErrRecordNotFound
8471 }
85728673 return &ai, nil