Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 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 | |
| 16 | class EventStep(object): |
| 17 | """ |
| 18 | All the event steps defined in each synchronizer needs to inherit from this class in order to be loaded |
| 19 | |
| 20 | Each step should define a technology, and either a `topics` or a `pattern`. The meaning of `topics` and `pattern` |
| 21 | depend on the technology that is chosen. |
| 22 | """ |
| 23 | |
| 24 | technology = "kafka" |
| 25 | topics = [] |
| 26 | pattern = None |
| 27 | |
Scott Baker | c2fddaa | 2019-01-30 15:45:03 -0800 | [diff] [blame] | 28 | def __init__(self, model_accessor, log, **kwargs): |
Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 29 | """ |
| 30 | Initialize a pull step. Override this function to include any initialization. Make sure to call the original |
| 31 | __init__() from your method. |
| 32 | """ |
| 33 | |
Scott Baker | c2fddaa | 2019-01-30 15:45:03 -0800 | [diff] [blame] | 34 | # self.model_accessor can be used to create and query models |
| 35 | self.model_accessor = model_accessor |
| 36 | |
Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 37 | # self.log can be used to emit logging messages. |
| 38 | self.log = log |
| 39 | |
| 40 | def process_event(self, event): |
| 41 | # This method must be overridden in your class. Do not call the original method. |
| 42 | |
| 43 | self.log.warning( |
| 44 | "There is no default process_event, please provide a process_event method", |
| 45 | msg=event, |
| 46 | ) |