|
| 1 | +# Copyright (C) 2015 MongoDB, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the 'License'); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an 'AS IS' BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +module Mongo |
| 16 | + class Server |
| 17 | + class Description |
| 18 | + class Inspector |
| 19 | + |
| 20 | + # Handles notifying the cluster that a standalone was discovered. |
| 21 | + # |
| 22 | + # @since 2.0.6 |
| 23 | + class StandaloneDiscovered |
| 24 | + include Event::Publisher |
| 25 | + |
| 26 | + # Instantiate the standalone discovered inspection. |
| 27 | + # |
| 28 | + # @example Instantiate the inspection. |
| 29 | + # StandaloneDiscovered.new(listeners) |
| 30 | + # |
| 31 | + # @param [ Event::Listeners ] event_listeners The event listeners. |
| 32 | + # |
| 33 | + # @since 2.0.6 |
| 34 | + def initialize(event_listeners) |
| 35 | + @event_listeners = event_listeners |
| 36 | + end |
| 37 | + |
| 38 | + # Run the standalone discovered inspection. |
| 39 | + # |
| 40 | + # @example Run the inspection. |
| 41 | + # StandaloneDiscovered.run(description, {}) |
| 42 | + # |
| 43 | + # @param [ Description ] description The server description. |
| 44 | + # @param [ Description ] updated The updated description. |
| 45 | + # |
| 46 | + # @since 2.0.6 |
| 47 | + def run(description, updated) |
| 48 | + if !description.standalone? && updated.standalone? |
| 49 | + publish(Event::STANDALONE_DISCOVERED, updated) |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | + end |
| 54 | + end |
| 55 | + end |
| 56 | +end |
0 commit comments