<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
syntax = "proto2";

package pulsar.proto;
option java_package = "org.apache.pulsar.common.api.proto";
option optimize_for = LITE_RUNTIME;

message Schema {
	enum Type {
		None = 0;
		String = 1;
		Json = 2;
		Protobuf = 3;
		Avro = 4;
	}

    required string name = 1;
    required bytes schema_data = 3;
	required Type type = 4;
    repeated KeyValue properties = 5;

}

message MessageIdData {
	required uint64 ledgerId = 1;
	required uint64 entryId  = 2;
	optional int32 partition = 3 [default = -1];
	optional int32 batch_index = 4 [default = -1];
}

message KeyValue {
	required string key = 1;
	required string value = 2;
}

message KeyLongValue {
        required string key = 1;
        required uint64 value = 2;
}

message EncryptionKeys {
	required string key = 1;
	required bytes value = 2;
	repeated KeyValue metadata = 3;
}

enum CompressionType {
	NONE   = 0;
	LZ4    = 1;
	ZLIB   = 2;
}

message MessageMetadata {
	required string producer_name   = 1;
	required uint64 sequence_id     = 2;
	required uint64 publish_time    = 3;
	repeated KeyValue properties    = 4;

	// Property set on replicated message,
	// includes the source cluster name
	optional string replicated_from = 5;
	//key to decide partition for the msg
	optional string partition_key   = 6;
	// Override namespace's replication
	repeated string replicate_to    = 7;
	optional CompressionType compression = 8 [default = NONE];
	optional uint32 uncompressed_size = 9 [default = 0];
	// Removed below checksum field from Metadata as
	// it should be part of send-command which keeps checksum of header + payload
	//optional sfixed64 checksum = 10;
	// differentiate single and batch message metadata
	optional int32 num_messages_in_batch = 11 [default = 1];

	// the timestamp that this event occurs. it is typically set by applications.
	// if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
	optional uint64 event_time = 12 [default = 0];
	// Contains encryption key name, encrypted key and metadata to describe the key
	repeated EncryptionKeys encryption_keys = 13;
	// Algorithm used to encrypt data key
	optional string encryption_algo = 14;
	// Additional parameters required by encryption
	optional bytes encryption_param = 15;
	optional bytes schema_version = 16;
}


message SingleMessageMetadata {
	repeated KeyValue properties    = 1;
	optional string partition_key   = 2;
	required int32 payload_size	= 3;
	optional bool compacted_out     = 4 [default = false];

	// the timestamp that this event occurs. it is typically set by applications.
	// if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
	optional uint64 event_time = 5 [default = 0];
}

enum ServerError {
    UnknownError        = 0;
	MetadataError       = 1; // Error with ZK/metadata
	PersistenceError    = 2; // Error writing reading from BK
	AuthenticationError = 3; // Non valid authentication
	AuthorizationError  = 4; // Not authorized to use resource

	ConsumerBusy        = 5; // Unable to subscribe/unsubscribe because
	                         // other consumers are connected
    ServiceNotReady     = 6; // Any error that requires client retry operation with a fresh lookup
    ProducerBlockedQuotaExceededError = 7; // Unable to create producer because backlog quota exceeded
    ProducerBlockedQuotaExceededException = 8; // Exception while creating producer because quota exceeded
    ChecksumError = 9; // Error while verifying message checksum
    UnsupportedVersionError = 10; // Error when an older client/version doesn't support a required feature
    TopicNotFound = 11; // Topic not found
    SubscriptionNotFound = 12; // Subscription not found
    ConsumerNotFound = 13; // Consumer not found
    TooManyRequests = 14; // Error with too many simultaneously request
    TopicTerminatedError = 15; // The topic has been terminated

    ProducerBusy         = 16; // Producer with same name is already connected
    InvalidTopicName = 17; // The topic name is not valid
}

enum AuthMethod {
	AuthMethodNone   = 0;
	AuthMethodYcaV1  = 1;
	AuthMethodAthens = 2;
}

// Each protocol version identify new features that are
// incrementally added to the protocol
enum ProtocolVersion {
	v0 = 0;  // Initial versioning
	v1 = 1;  // Added application keep-alive
	v2 = 2;  // Added RedeliverUnacknowledgedMessages Command
	v3 = 3;  // Added compression with LZ4 and ZLib
	v4 = 4;  // Added batch message support
	v5 = 5;  // Added disconnect client w/o closing connection
	v6 = 6;  // Added checksum computation for metadata + payload
	v7 = 7;  // Added CommandLookupTopic - Binary Lookup
	v8 = 8;  // Added CommandConsumerStats - Client fetches broker side consumer stats
	v9 = 9;  // Added end of topic notification
	v10 = 10;// Added proxy to broker
	v11 = 11;// C++ consumers before this version are not correctly handling the checksum field
	v12 = 12;// Added get topic's last messageId from broker
			 // Added CommandActiveConsumerChange
			 // Added CommandGetTopicsOfNamespace
	v13 = 13;
}

message CommandConnect {
	required string client_version = 1;
	optional AuthMethod auth_method = 2; // Deprecated. Use "auth_method_name" instead.
	optional string auth_method_name = 5;
	optional bytes auth_data = 3;
	optional int32 protocol_version = 4 [default = 0];

	// Client can ask to be proxyied to a specific broker
	// This is only honored by a Pulsar proxy
	optional string proxy_to_broker_url = 6;

	// Original principal that was verified by
	// a Pulsar proxy. In this case the auth info above
	// will be the auth of the proxy itself
	optional string original_principal = 7;

	// Original auth role and auth Method that was passed
	// to the proxy. In this case the auth info above
	// will be the auth of the proxy itself
	optional string original_auth_data = 8;<commit_msg>Add pulsar-version comment for future reference (#2163)<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
syntax = "proto2";

package pulsar.proto;
option java_package = "org.apache.pulsar.common.api.proto";
option optimize_for = LITE_RUNTIME;

message Schema {
	enum Type {
		None = 0;
		String = 1;
		Json = 2;
		Protobuf = 3;
		Avro = 4;
	}

    required string name = 1;
    required bytes schema_data = 3;
	required Type type = 4;
    repeated KeyValue properties = 5;

}

message MessageIdData {
	required uint64 ledgerId = 1;
	required uint64 entryId  = 2;
	optional int32 partition = 3 [default = -1];
	optional int32 batch_index = 4 [default = -1];
}

message KeyValue {
	required string key = 1;
	required string value = 2;
}

message KeyLongValue {
        required string key = 1;
        required uint64 value = 2;
}

message EncryptionKeys {
	required string key = 1;
	required bytes value = 2;
	repeated KeyValue metadata = 3;
}

enum CompressionType {
	NONE   = 0;
	LZ4    = 1;
	ZLIB   = 2;
}

message MessageMetadata {
	required string producer_name   = 1;
	required uint64 sequence_id     = 2;
	required uint64 publish_time    = 3;
	repeated KeyValue properties    = 4;

	// Property set on replicated message,
	// includes the source cluster name
	optional string replicated_from = 5;
	//key to decide partition for the msg
	optional string partition_key   = 6;
	// Override namespace's replication
	repeated string replicate_to    = 7;
	optional CompressionType compression = 8 [default = NONE];
	optional uint32 uncompressed_size = 9 [default = 0];
	// Removed below checksum field from Metadata as
	// it should be part of send-command which keeps checksum of header + payload
	//optional sfixed64 checksum = 10;
	// differentiate single and batch message metadata
	optional int32 num_messages_in_batch = 11 [default = 1];

	// the timestamp that this event occurs. it is typically set by applications.
	// if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
	optional uint64 event_time = 12 [default = 0];
	// Contains encryption key name, encrypted key and metadata to describe the key
	repeated EncryptionKeys encryption_keys = 13;
	// Algorithm used to encrypt data key
	optional string encryption_algo = 14;
	// Additional parameters required by encryption
	optional bytes encryption_param = 15;
	optional bytes schema_version = 16;
}


message SingleMessageMetadata {
	repeated KeyValue properties    = 1;
	optional string partition_key   = 2;
	required int32 payload_size	= 3;
	optional bool compacted_out     = 4 [default = false];

	// the timestamp that this event occurs. it is typically set by applications.
	// if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
	optional uint64 event_time = 5 [default = 0];
}

enum ServerError {
    UnknownError        = 0;
	MetadataError       = 1; // Error with ZK/metadata
	PersistenceError    = 2; // Error writing reading from BK
	AuthenticationError = 3; // Non valid authentication
	AuthorizationError  = 4; // Not authorized to use resource

	ConsumerBusy        = 5; // Unable to subscribe/unsubscribe because
	                         // other consumers are connected
    ServiceNotReady     = 6; // Any error that requires client retry operation with a fresh lookup
    ProducerBlockedQuotaExceededError = 7; // Unable to create producer because backlog quota exceeded
    ProducerBlockedQuotaExceededException = 8; // Exception while creating producer because quota exceeded
    ChecksumError = 9; // Error while verifying message checksum
    UnsupportedVersionError = 10; // Error when an older client/version doesn't support a required feature
    TopicNotFound = 11; // Topic not found
    SubscriptionNotFound = 12; // Subscription not found
    ConsumerNotFound = 13; // Consumer not found
    TooManyRequests = 14; // Error with too many simultaneously request
    TopicTerminatedError = 15; // The topic has been terminated

    ProducerBusy         = 16; // Producer with same name is already connected
    InvalidTopicName = 17; // The topic name is not valid
}

enum AuthMethod {
	AuthMethodNone   = 0;
	AuthMethodYcaV1  = 1;
	AuthMethodAthens = 2;
}

// Each protocol version identify new features that are
// incrementally added to the protocol
enum ProtocolVersion {
	v0 = 0;  // Initial versioning
	v1 = 1;  // Added application keep-alive
	v2 = 2;  // Added RedeliverUnacknowledgedMessages Command
	v3 = 3;  // Added compression with LZ4 and ZLib
	v4 = 4;  // Added batch message support
	v5 = 5;  // Added disconnect client w/o closing connection
	v6 = 6;  // Added checksum computation for metadata + payload
	v7 = 7;  // Added CommandLookupTopic - Binary Lookup
	v8 = 8;  // Added CommandConsumerStats - Client fetches broker side consumer stats
	v9 = 9;  // Added end of topic notification
	v10 = 10;// Added proxy to broker
	v11 = 11;// C++ consumers before this version are not correctly handling the checksum field
	v12 = 12;// Added get topic's last messageId from broker
			 // Added CommandActiveConsumerChange
			 // Added CommandGetTopicsOfNamespace
	v13 = 13; // Schema-registry : added avro schema format for json
}

message CommandConnect {
	required string client_version = 1;
	optional AuthMethod auth_method = 2; // Deprecated. Use "auth_method_name" instead.
	optional string auth_method_name = 5;
	optional bytes auth_data = 3;
	optional int32 protocol_version = 4 [default = 0];

	// Client can ask to be proxyied to a specific broker
	// This is only honored by a Pulsar proxy
	optional string proxy_to_broker_url = 6;

	// Original principal that was verified by
	// a Pulsar proxy. In this case the auth info above
	// will be the auth of the proxy itself
	optional string original_principal = 7;

	// Original auth role and auth Method that was passed
	// to the proxy. In this case the auth info above
	// will be the auth of the proxy itself
	optional string original_auth_data = 8;
{'fraction_non_alphanumeric': 0.06835310797701664, 'fraction_numerical': 0.025221998358331468, 'mean_word_length': 3.4172709294660515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5441305', 'n_tokens_mistral': 4032, 'n_tokens_neox': 3630, 'n_words': 1626}