package com.atlassian.bitbucket.mesh.git;

import com.atlassian.bitbucket.mesh.git.hosting.GitReceivePackListener;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcHostingStreamResult;
import com.atlassian.bitbucket.mesh.rpc.v1.RpcStreamChunk;

import javax.annotation.Nonnull;

/**
 * Responsible for detecting gRPC pushes that do not invoke the expected git hooks. When such a push is
 * detected, the following information about the push request is logged:
 * <ul>
 *     <li>the exit code</li>
 *     <li>the first n bytes (configurable) of the stdin provided by the client</li>
 *     <li>the first n bytes (configurable) of git stdout</li>
 *     <li>the first n bytes (configurable) of git stderr</li>
 *     <li>whether the pre-receive hook was invoked and if so, what the exit code was</li>
 *     <li>whether the post-receive hook was invoked and if so, what the exit code was</li>
 * </ul>
 *
 * @since 1.3
 */
public interface GrpcPushTracer extends GitReceivePackListener {

    void onPostReceive(int exitCode);

    void onPreReceive(int exitCode);

    void onResult(@Nonnull RpcHostingStreamResult result);

    void onStdout(@Nonnull RpcStreamChunk chunk);

    void onStderr(@Nonnull RpcStreamChunk chunk);
}
