• Cristian Maglie's avatar
    Fix gRPC `BoardList*` methods concurrency issues (#1804) · 9c334ed8
    Cristian Maglie authored
    * Improved streaming of pluggable-discoveries events (WIP)
    
    Now the DiscoveryManager is able to start the discoveries and add/remove
    them in a thread-safe way. Also the watchers may connect and disconnect
    seamlessly at any time, the incoming events from the discovery are
    broadcasted correctly to each active watcher.
    
    This refactoring dramatically simplifies the DiscoveryManager design.
    
    * Added discovery id in discovery.Event struct
    
    * Cache active ports and transmit them when a new watcher connects
    
    * Correctly handle discovery cleanup
    
    * Fixed wrong test
    
    * Correctly handle discovery cleanup and re-add
    
    * Added some doc comments in the source code
    
    * Move Unlock under defer
    
    * Factored subrotuine into a function
    
    it will be useful in the next commits.
    
    * Do not cache ports in the DiscoveryClient
    
    there is already a cache in the DiscoveryManager there is no need to
    duplicate it.
    
    * Discovery: eventChan must be protected by mutex when doing START_SYNC
    
    otherwise the discovery may send some events before the eventChan is
    setup (and those events will be lost)
    
    * Increased error level for logging watchers that lags
    
    * Updated discvoery_client to the latest API
    
    * Report discovery start errors
    
    * Update arduino/discovery/discovery_client/main.go
    Co-authored-by: default avatarUmberto Baldi <34278123+umbynos@users.noreply.github.com>
    Co-authored-by: default avatarUmberto Baldi <34278123+umbynos@users.noreply.github.com>
    9c334ed8
discovery.go 13.4 KB