All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.finos.tracdap.svc.meta.api.TrustedMetadataApi Maven / Gradle / Ivy

Go to download

TRAC D.A.P. metadata service, stateless service component to answer the TRAC metadata API

There is a newer version: 0.6.3
Show newest version
/*
 * Copyright 2022 Accenture Global Solutions Limited
 *
 * 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.
 */

package org.finos.tracdap.svc.meta.api;

import com.google.protobuf.Descriptors;
import org.finos.tracdap.api.*;
import org.finos.tracdap.common.exception.EUnexpected;
import org.finos.tracdap.common.grpc.GrpcServerWrap;
import org.finos.tracdap.metadata.Tag;
import org.finos.tracdap.metadata.TagHeader;
import org.finos.tracdap.svc.meta.services.MetadataReadService;
import org.finos.tracdap.svc.meta.services.MetadataSearchService;
import org.finos.tracdap.svc.meta.services.MetadataWriteService;
import io.grpc.MethodDescriptor;
import io.grpc.stub.StreamObserver;
import org.finos.tracdap.svc.meta.services.MetadataConstants;


public class TrustedMetadataApi extends TrustedMetadataApiGrpc.TrustedMetadataApiImplBase {

    private static final String SERVICE_NAME = TrustedMetadataApiGrpc.SERVICE_NAME.substring(TrustedMetadataApiGrpc.SERVICE_NAME.lastIndexOf(".") + 1);
    private static final Descriptors.ServiceDescriptor TRUSTED_METADATA_SERVICE = MetadataTrusted.getDescriptor().findServiceByName(SERVICE_NAME);

    static final MethodDescriptor PREALLOCATE_ID_METHOD = TrustedMetadataApiGrpc.getPreallocateIdMethod();
    static final MethodDescriptor CREATE_PREALLOCATED_OBJECT_METHOD = TrustedMetadataApiGrpc.getCreatePreallocatedObjectMethod();



    private final MetadataApiImpl apiImpl;
    private final GrpcServerWrap grpcWrap;

    public TrustedMetadataApi(
            MetadataReadService readService,
            MetadataWriteService writeService,
            MetadataSearchService searchService) {

        if (TRUSTED_METADATA_SERVICE == null)
            throw new EUnexpected();

        apiImpl = new MetadataApiImpl(TRUSTED_METADATA_SERVICE, readService, writeService, searchService, MetadataConstants.TRUSTED_API);
        grpcWrap = new GrpcServerWrap();
    }

    @Override
    public void writeBatch(MetadataWriteBatchRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::writeBatch);
    }

    @Override
    public void createObject(MetadataWriteRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::createObject);
    }

    @Override
    public void updateObject(MetadataWriteRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::updateObject);
    }

    @Override
    public void updateTag(MetadataWriteRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::updateTag);
    }

    @Override
    public void preallocateId(MetadataWriteRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::preallocateId);
    }

    @Override
    public void createPreallocatedObject(MetadataWriteRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::createPreallocatedObject);
    }

    @Override
    public void readObject(MetadataReadRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::readObject);
    }

    @Override
    public void readBatch(MetadataBatchRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::readBatch);
    }

    @Override
    public void search(MetadataSearchRequest request, StreamObserver response) {

        grpcWrap.unaryCall(request, response, apiImpl::search);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy