syntax = "proto3";

option go_package = "github.com/hatchet-dev/hatchet/internal/services/ingestor/contracts";

import "google/protobuf/timestamp.proto";

service EventsService {
    rpc Push(PushEventRequest) returns (Event) {}

    rpc BulkPush(BulkPushEventRequest) returns (Events) {}

    rpc ReplaySingleEvent(ReplayEventRequest) returns (Event) {}

    rpc PutLog(PutLogRequest) returns (PutLogResponse) {}

    rpc PutStreamEvent(PutStreamEventRequest) returns (PutStreamEventResponse) {}
}

message Event {
    // the tenant id
    string tenant_id = 1;

    // the id of the event
    string event_id = 2;

    // the key for the event
    string key = 3;

    // the payload for the event
    string payload = 4;

    // when the event was generated
    google.protobuf.Timestamp event_timestamp = 5;

    // the additional metadata for the event
    optional string additional_metadata = 6;

    // the scope associated with this filter. Used for subsetting candidate filters at evaluation time
    optional string scope = 7;

}

message Events {
    repeated Event events = 1;
}

message PutLogRequest {
    // the task external run id for the request
    string task_run_external_id = 1;

    // when the log line was created
    google.protobuf.Timestamp created_at = 2;

    // the log line message
    string message = 3;

    // the log line level
    optional string level = 4;

    // associated log line metadata
    string metadata = 5;

    // the retry count of the task run
    optional int32 task_retry_count = 6;
}

message PutLogResponse {}

message PutStreamEventRequest {
    // the task external run id for the request
    string task_run_external_id = 1;

    // when the stream event was created
    google.protobuf.Timestamp created_at = 2;

    // the stream event message
    bytes message = 3;

    // associated stream event metadata
    string metadata = 5;

    optional int64 event_index = 6;
}

message PutStreamEventResponse {}


message BulkPushEventRequest {

    repeated PushEventRequest events = 1;
}

message PushEventRequest {
    // the key for the event
    string key = 1;

    // the payload for the event
    string payload = 2;

    // when the event was generated
    google.protobuf.Timestamp event_timestamp = 3;

    // metadata for the event
    optional string additional_metadata = 4;

    optional int32 priority = 5;

    // the scope associated with this filter. Used for subsetting candidate filters at evaluation time
    optional string scope = 6;
}

message ReplayEventRequest {
    // the event id to replay
    string event_id = 1;
}
