Skip to content

Commit

Permalink
Merge pull request #15 from ShareChat/xds-cache
Browse files Browse the repository at this point in the history
Add zerolog, update BatchUpsertResources
  • Loading branch information
krhitesh7 authored Sep 29, 2024
2 parents 5841acc + 0adb568 commit 55f4a98
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions pkg/cache/v3/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,35 +293,32 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string
info.mu.Unlock()
}
} else {
resources := make(map[resource.Type][]types.ResourceWithTTL)
resources[typ] = make([]types.ResourceWithTTL, 0)
for _, r := range resourcesUpserted {
//if typ == resource.EndpointType {
// cla := r.Resource.(*endpoint.ClusterLoadAssignment)
// if len(cla.Endpoints) == 0 {
// log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints))
// }
//}
resources[typ] = append(resources[typ], *r)
}
s, err := NewSnapshotWithTTLs("0", resources)
if err != nil {
continue
}
cache.snapshots[node] = s

// Respond deltas
if info, ok := cache.status[node]; ok {
info.mu.Lock()
log2.Info().Msgf("BatchUpsertResources: Not writing to cache as snapshot does not exist [node=%s][typeUrl=%s]", node, typ)
return nil

// Respond to delta watches for the node.
err := cache.respondDeltaWatches(ctx, info, s)
if err != nil {
info.mu.Unlock()
continue
}
info.mu.Unlock()
}
//resources := make(map[resource.Type][]types.ResourceWithTTL)
//resources[typ] = make([]types.ResourceWithTTL, 0)
//for _, r := range resourcesUpserted {
// resources[typ] = append(resources[typ], *r)
//}
//s, err := NewSnapshotWithTTLs("0", resources)
//if err != nil {
// continue
//}
//cache.snapshots[node] = s
//
//// Respond deltas
//if info, ok := cache.status[node]; ok {
// info.mu.Lock()
//
// // Respond to delta watches for the node.
// err := cache.respondDeltaWatches(ctx, info, s)
// if err != nil {
// info.mu.Unlock()
// continue
// }
// info.mu.Unlock()
//}
}
}

Expand Down

0 comments on commit 55f4a98

Please sign in to comment.