syntax = “proto3”; package event_store.client.persistent_subscriptions; option java_package = “com.eventstore.dbclient.proto.persistentsubscriptions”;

import “shared.proto”;

service PersistentSubscriptions {

rpc Create (CreateReq) returns (CreateResp);
rpc Update (UpdateReq) returns (UpdateResp);
rpc Delete (DeleteReq) returns (DeleteResp);
rpc Read (stream ReadReq) returns (stream ReadResp);

}

message ReadReq {

oneof content {
        Options options = 1;
        Ack ack = 2;
        Nack nack = 3;
}

message Options {
        event_store.client.shared.StreamIdentifier stream_identifier = 1;
        string group_name = 2;
        int32 buffer_size = 3;
        UUIDOption uuid_option = 4;

        message UUIDOption {
                oneof content {
                        event_store.client.shared.Empty structured = 1;
                        event_store.client.shared.Empty string = 2;
                }
        }
}

message Ack {
        bytes id = 1;
        repeated event_store.client.shared.UUID ids = 2;
}

message Nack {
        bytes id = 1;
        repeated event_store.client.shared.UUID ids = 2;
        Action action = 3;
        string reason = 4;

        enum Action {
                Unknown = 0;
                Park = 1;
                Retry = 2;
                Skip = 3;
                Stop = 4;
        }
}

}

message ReadResp {

oneof content {
        ReadEvent event = 1;
        SubscriptionConfirmation subscription_confirmation = 2;
}
message ReadEvent {
        RecordedEvent event = 1;
        RecordedEvent link = 2;
        oneof position {
                uint64 commit_position = 3;
                event_store.client.shared.Empty no_position = 4;
        }
        oneof count {
                int32 retry_count = 5;
                event_store.client.shared.Empty no_retry_count = 6;
        }
        message RecordedEvent {
                event_store.client.shared.UUID id = 1;
                event_store.client.shared.StreamIdentifier stream_identifier = 2;
                uint64 stream_revision = 3;
                uint64 prepare_position = 4;
                uint64 commit_position = 5;
                map<string, string> metadata = 6;
                bytes custom_metadata = 7;
                bytes data = 8;
        }
}
message SubscriptionConfirmation {
        string subscription_id = 1;
}

}

message CreateReq {

Options options = 1;

message Options {
        event_store.client.shared.StreamIdentifier stream_identifier = 1;
        string group_name = 2;
        Settings settings = 3;
}

message Settings {
        bool resolve_links = 1;
        uint64 revision = 2;
        bool extra_statistics = 3;
        int32 max_retry_count = 5;
        int32 min_checkpoint_count = 7;
        int32 max_checkpoint_count = 8;
        int32 max_subscriber_count = 9;
        int32 live_buffer_size = 10;
        int32 read_batch_size = 11;
        int32 history_buffer_size = 12;
        ConsumerStrategy named_consumer_strategy = 13;
        oneof message_timeout {
                int64 message_timeout_ticks = 4;
                int32 message_timeout_ms = 14;
        }
        oneof checkpoint_after {
                int64 checkpoint_after_ticks = 6;
                int32 checkpoint_after_ms = 15;
        }
}

enum ConsumerStrategy {
        DispatchToSingle = 0;
        RoundRobin = 1;
        Pinned = 2;
}

}

message CreateResp { }

message UpdateReq {

Options options = 1;

message Options {
        event_store.client.shared.StreamIdentifier stream_identifier = 1;
        string group_name = 2;
        Settings settings = 3;
}

message Settings {
        bool resolve_links = 1;
        uint64 revision = 2;
        bool extra_statistics = 3;
        int32 max_retry_count = 5;
        int32 min_checkpoint_count = 7;
        int32 max_checkpoint_count = 8;
        int32 max_subscriber_count = 9;
        int32 live_buffer_size = 10;
        int32 read_batch_size = 11;
        int32 history_buffer_size = 12;
        ConsumerStrategy named_consumer_strategy = 13;
        oneof message_timeout {
                int64 message_timeout_ticks = 4;
                int32 message_timeout_ms = 14;
        }
        oneof checkpoint_after {
                int64 checkpoint_after_ticks = 6;
                int32 checkpoint_after_ms = 15;
        }
}

enum ConsumerStrategy {
        DispatchToSingle = 0;
        RoundRobin = 1;
        Pinned = 2;
}

}

message UpdateResp { }

message DeleteReq {

Options options = 1;

message Options {
        event_store.client.shared.StreamIdentifier stream_identifier = 1;
        string group_name = 2;
}

}

message DeleteResp { }