package com.atlassian.bitbucket.mesh.git;

import com.atlassian.bitbucket.mesh.git.hook.script.HookScriptManager;
import com.atlassian.bitbucket.mesh.repository.RepositoryManager;
import com.atlassian.bitbucket.mesh.rpc.v1.HookScriptServiceGrpc;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcCallHookScriptsFragment;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcCallHookScriptsResponseFragment;
import io.grpc.stub.StreamObserver;

public class GrpcHookScriptService extends HookScriptServiceGrpc.HookScriptServiceImplBase {

    private final HookScriptManager hookScriptManager;
    private final RepositoryManager repositoryManager;

    public GrpcHookScriptService(HookScriptManager hookScriptManager, RepositoryManager repositoryManager) {
        this.hookScriptManager = hookScriptManager;
        this.repositoryManager = repositoryManager;
    }

    @Override
    public StreamObserver<RpcCallHookScriptsFragment> callHookScripts(
            StreamObserver<RpcCallHookScriptsResponseFragment> responseObserver) {
        return new CallHookScriptsRequestObserver(hookScriptManager, repositoryManager, responseObserver);
    }
}
