@@ -85,12 +85,14 @@ type Datastore struct {
8585// func New(c *config.DatastoreConfig, schemaServer *config.RemoteSchemaServer) *Datastore {
8686func New (ctx context.Context , c * config.DatastoreConfig , scc schema.Client , cc cache.Client , opts ... grpc.DialOption ) * Datastore {
8787 ds := & Datastore {
88- config : c ,
89- schemaClient : scc ,
90- cacheClient : cc ,
91- intentMutex : new (sync.Mutex ),
92- m : new (sync.RWMutex ),
93- deviationClients : make (map [string ]sdcpb.DataServer_WatchDeviationsServer ),
88+ config : c ,
89+ schemaClient : scc ,
90+ cacheClient : cc ,
91+ intentMutex : new (sync.Mutex ),
92+ m : new (sync.RWMutex ),
93+ deviationClients : make (map [string ]sdcpb.DataServer_WatchDeviationsServer ),
94+ md : new (sync.RWMutex ),
95+ currentIntentsDeviations : make (map [string ][]* sdcpb.WatchDeviationResponse ),
9496 }
9597 if c .Sync != nil {
9698 ds .synCh = make (chan * target.SyncUpdate , c .Sync .Buffer )
@@ -1102,6 +1104,9 @@ func (d *Datastore) runDeviationUpdate(ctx context.Context, dm map[string]sdcpb.
11021104 }
11031105 }
11041106 xp := utils .ToXPath (sp , false )
1107+ if _ , ok := newDeviations [xp ]; ! ok {
1108+ newDeviations [xp ] = make ([]* sdcpb.WatchDeviationResponse , 0 , 1 )
1109+ }
11051110 newDeviations [xp ] = append (newDeviations [xp ], rsp )
11061111 }
11071112 // remaining intents
@@ -1148,6 +1153,9 @@ func (d *Datastore) runDeviationUpdate(ctx context.Context, dm map[string]sdcpb.
11481153 }
11491154 }
11501155 xp := utils .ToXPath (sp , false )
1156+ if _ , ok := newDeviations [xp ]; ! ok {
1157+ newDeviations [xp ] = make ([]* sdcpb.WatchDeviationResponse , 0 , 1 )
1158+ }
11511159 newDeviations [xp ] = append (newDeviations [xp ], rsp )
11521160 }
11531161 }
0 commit comments