2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
25 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
28 type NotificationHandlerProvider struct{
29 notificationHandlers map[int]handlers.NotificationHandler
30 rnibReaderProvider func() reader.RNibReader
31 rnibWriterProvider func() rNibWriter.RNibWriter
34 func NewNotificationHandlerProvider(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) *NotificationHandlerProvider {
35 return &NotificationHandlerProvider{
36 rnibReaderProvider: rnibReaderProvider,
37 rnibWriterProvider: rnibWriterProvider,
38 notificationHandlers: initNotificationHandlersMap(rnibReaderProvider, rnibWriterProvider),
42 func initNotificationHandlersMap(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) map[int]handlers.NotificationHandler{
43 return map[int]handlers.NotificationHandler{
44 //TODO change handlers.NotificationHandler to *handlers.NotificationHandler
45 rmrCgo.RIC_X2_SETUP_RESP: handlers.X2SetupResponseNotificationHandler{},
46 rmrCgo.RIC_X2_SETUP_FAILURE: handlers.X2SetupFailureResponseNotificationHandler{},
47 rmrCgo.RIC_ENDC_X2_SETUP_RESP: handlers.EndcX2SetupResponseNotificationHandler{},
48 rmrCgo.RIC_ENDC_X2_SETUP_FAILURE: handlers.EndcX2SetupFailureResponseNotificationHandler{},
49 rmrCgo.RIC_SCTP_CONNECTION_FAILURE: handlers.NewRanLostConnectionHandler(rnibReaderProvider, rnibWriterProvider),
50 rmrCgo.RIC_ENB_LOAD_INFORMATION: handlers.RicEnbLoadInformationNotificationHandler{},
51 rmrCgo.RIC_ENB_CONF_UPDATE: handlers.X2EnbConfigurationUpdateHandler{},
52 rmrCgo.RIC_ENDC_CONF_UPDATE: handlers.EndcConfigurationUpdateHandler{},
53 rmrCgo.RIC_X2_RESET_RESP: handlers.NewX2ResetResponseHandler(rnibReaderProvider),
57 func (provider NotificationHandlerProvider) GetNotificationHandler(messageType int) (handlers.NotificationHandler, error) {
58 handler, ok := provider.notificationHandlers[messageType]
61 return nil, fmt.Errorf("notification handler not found for message %d",messageType)