# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


    @safe_and_metered_rpc_method(METRICS, LOGGER)
    def GetContextEvents(self, request : Empty, context : grpc.ServicerContext) -> Iterator[ContextEvent]:
        pass
        #for message in self.messagebroker.consume({TOPIC_CONTEXT}, consume_timeout=CONSUME_TIMEOUT):
        #    yield ContextEvent(**json.loads(message.content))
        #cf = ChangeFeedClient()
        #ready = cf.initialize()
        #if not ready: raise OperationFailedException('Initialize ChangeFeed')
        #for timestamp, _, primary_key, is_delete, after in cf.get_changes('context'):
        #    if is_delete:
        #        event_type = EventTypeEnum.EVENTTYPE_REMOVE
        #    else:
        #        is_create = (timestamp - after.get('created_at')) < 1.0
        #        event_type = EventTypeEnum.EVENTTYPE_CREATE if is_create else EventTypeEnum.EVENTTYPE_UPDATE
        #    event = {
        #        'event': {'timestamp': {'timestamp': timestamp}, 'event_type': event_type},
        #        'context_id': json_context_id(primary_key[0]),
        #    }
        #    yield ContextEvent(**event)
