Start makes a first sync and setup watchers
(ctx context.Context, withWatches bool)
| 98 | |
| 99 | // Start makes a first sync and setup watchers |
| 100 | func (s *Sync) Start(ctx context.Context, withWatches bool) { |
| 101 | |
| 102 | // Init processor |
| 103 | s.processor = proc.NewConnectedProcessor(ctx, s.cmd) |
| 104 | if s.SkipTargetChecks { |
| 105 | s.processor.SkipTargetChecks = true |
| 106 | } |
| 107 | s.patchChan = s.processor.PatchChan |
| 108 | if s.patchListener != nil { |
| 109 | s.processor.PatchListener = s.patchListener |
| 110 | } |
| 111 | s.processor.Ignores = s.Ignores |
| 112 | s.processor.Start() |
| 113 | |
| 114 | // Init EchoFilter |
| 115 | if s.Direction == model.DirectionBi { |
| 116 | s.echoFilter = filters.NewEchoFilter() |
| 117 | s.processor.SetLocksChan(s.echoFilter.GetLocksChan()) |
| 118 | s.echoFilter.Start() |
| 119 | } |
| 120 | |
| 121 | if withWatches { |
| 122 | s.startWatchers(ctx) |
| 123 | } else if s.watchConn != nil { |
| 124 | go func() { |
| 125 | <-time.After(2 * time.Second) |
| 126 | s.watchConn <- &model.EndpointStatus{ |
| 127 | WatchConnection: model.WatchConnected, |
| 128 | EndpointInfo: s.Source.GetEndpointInfo(), |
| 129 | } |
| 130 | s.watchConn <- &model.EndpointStatus{ |
| 131 | WatchConnection: model.WatchConnected, |
| 132 | EndpointInfo: s.Target.GetEndpointInfo(), |
| 133 | } |
| 134 | }() |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | |
| 139 | // Pause should pause the sync |
| 140 | func (s *Sync) Pause(ctx context.Context) { |
no test coverage detected