github.com/cs3org/reva/v2@v2.27.7/pkg/mentix/connectors/connector.go (about)

     1  // Copyright 2018-2021 CERN
     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  // In applying this license, CERN does not waive the privileges and immunities
    16  // granted to it by virtue of its status as an Intergovernmental Organization
    17  // or submit itself to any jurisdiction.
    18  
    19  package connectors
    20  
    21  import (
    22  	"fmt"
    23  
    24  	"github.com/rs/zerolog"
    25  
    26  	"github.com/cs3org/reva/v2/pkg/mentix/config"
    27  	"github.com/cs3org/reva/v2/pkg/mentix/entity"
    28  	"github.com/cs3org/reva/v2/pkg/mentix/meshdata"
    29  )
    30  
    31  // Connector is the interface that all connectors must implement.
    32  type Connector interface {
    33  	entity.Entity
    34  
    35  	// RetrieveMeshData fetches new mesh data.
    36  	RetrieveMeshData() (*meshdata.MeshData, error)
    37  	// UpdateMeshData updates the provided mesh data on the target side. The provided data only contains the data that
    38  	// should be updated, not the entire data set.
    39  	UpdateMeshData(data *meshdata.MeshData) error
    40  }
    41  
    42  // BaseConnector implements basic connector functionality common to all connectors.
    43  type BaseConnector struct {
    44  	conf *config.Configuration
    45  	log  *zerolog.Logger
    46  }
    47  
    48  // Activate activates the connector.
    49  func (connector *BaseConnector) Activate(conf *config.Configuration, log *zerolog.Logger) error {
    50  	if conf == nil {
    51  		return fmt.Errorf("no configuration provided")
    52  	}
    53  	connector.conf = conf
    54  
    55  	if log == nil {
    56  		return fmt.Errorf("no logger provided")
    57  	}
    58  	connector.log = log
    59  
    60  	return nil
    61  }
    62  
    63  // UpdateMeshData updates the provided mesh data on the target side. The provided data only contains the data that
    64  // should be updated, not the entire data set.
    65  func (connector *BaseConnector) UpdateMeshData(data *meshdata.MeshData) error {
    66  	return fmt.Errorf("the connector doesn't support updating of mesh data")
    67  }