Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 10, 2022. It is now read-only.
/kafka-phpPublic archive

Commit873e6f1

Browse files
committed
Producer support input empty key
1 parent0cf92da commit873e6f1

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

‎.php_cs.cache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"5.5.26","version":"2.1.0","rules":{"encoding":true,"full_opening_tag":true,"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":["property"],"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true},"hashes":{"src\/Kafka\/Exception.php":1887794156,"src\/Kafka\/Exception\/NotSupported.php":2083554785,"src\/Kafka\/Exception\/OutOfRange.php":613717588,"src\/Kafka\/Exception\/Protocol.php":2787269416,"src\/Kafka\/Exception\/Socket.php":2743402340,"src\/Kafka\/Exception\/SocketConnect.php":2883015980,"src\/Kafka\/Exception\/SocketEOF.php":1195314501,"src\/Kafka\/Exception\/SocketTimeout.php":1079612001,"src\/Kafka\/Exception\/Config.php":2153825859,"src\/Kafka\/Protocol\/CommitOffset.php":3711823135,"src\/Kafka\/Protocol\/Fetch.php":4166817029,"src\/Kafka\/Protocol\/FetchOffset.php":2615769477,"src\/Kafka\/Protocol\/GroupCoordinator.php":3030713974,"src\/Kafka\/Protocol\/Heartbeat.php":3269486857,"src\/Kafka\/Protocol\/JoinGroup.php":332592611,"src\/Kafka\/Protocol\/Metadata.php":1609652106,"src\/Kafka\/Protocol\/Offset.php":3262177831,"src\/Kafka\/Protocol\/Produce.php":1894065123,"src\/Kafka\/Protocol\/Protocol.php":476565724,"src\/Kafka\/Protocol\/SyncGroup.php":3584049845,"src\/Kafka\/Protocol.php":338507625,"src\/Kafka\/SingletonTrait.php":3424400384,"src\/Kafka\/Socket.php":1512067958,"src\/Kafka\/ConsumerConfig.php":2320744655,"src\/Kafka\/ProducerConfig.php":1925922788,"src\/Kafka\/Config.php":913412482,"src\/Kafka\/Broker.php":598094486,"src\/Kafka\/Consumer.php":674526766,"src\/Kafka\/Consumer\/Assignment.php":626810662,"src\/Kafka\/Consumer\/Process.php":511720065,"src\/Kafka\/Consumer\/State.php":1179310365,"src\/Kafka\/LoggerTrait.php":1234965748,"src\/Kafka\/Producer.php":2558655402,"src\/Kafka\/Producer\/State.php":3349306988,"src\/Kafka\/Producer\/Process.php":3384630694,"tests\/KafkaMock\/Protocol\/Encoder.php":1383970351,"tests\/KafkaTest\/ClientTest.php":347003966,"tests\/KafkaTest\/Produce\/ProduceTest.php":868593207,"tests\/KafkaTest\/Protocol\/DecoderTest.php":1953905898,"tests\/KafkaTest\/Protocol\/EncoderTest.php":118406869,"tests\/TestConfiguration.php":1872544484,"tests\/_autoload.php":2725147420,"tests\/run-tests.php":4228663547,"tests\/Bootstrap.php":3397345411,"tests\/KafkaTest\/Protocol\/GroupCoordinatorTest.php":3938006454,"tests\/KafkaTest\/Base\/ProtocolTest.php":3926873193,"tests\/KafkaTest\/Base\/BrokerTest.php":3957314909,"tests\/KafkaTest\/Base\/ConsumerConfigTest.php":901088941,"tests\/KafkaTest\/Base\/ProducerConfigTest.php":1821493122,"tests\/KafkaTest\/Protocol\/ProduceTest.php":3670305798,"tests\/KafkaTest\/Protocol\/OffsetTest.php":3799352786,"tests\/KafkaTest\/Protocol\/FetchTest.php":2392957613,"tests\/KafkaTest\/Protocol\/CommitOffsetTest.php":3999089971,"tests\/KafkaTest\/Protocol\/SyncGroupTest.php":1695142498,"tests\/KafkaTest\/Protocol\/HeartbeatTest.php":3012473440,"tests\/KafkaTest\/Protocol\/FetchOffsetTest.php":1945252662,"tests\/KafkaTest\/Protocol\/MetadataTest.php":1723320331,"tests\/KafkaTest\/Protocol\/JoinGroupTest.php":3735777277,"src\/Kafka\/Protocol\/LeaveGroup.php":3263763308,"src\/Kafka\/Protocol\/ListGroup.php":3673950913,"src\/Kafka\/Protocol\/DescribeGroups.php":1369242879,"tests\/KafkaTest\/Protocol\/LeaveGroupTest.php":1567634470,"tests\/KafkaTest\/Protocol\/DescribeGroupsTest.php":759837642,"tests\/KafkaTest\/Protocol\/ListGroupTest.php":3375737744}}
1+
{"php":"5.5.26","version":"2.1.0","rules":{"encoding":true,"full_opening_tag":true,"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":["property"],"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true},"hashes":{"src\/Kafka\/Exception.php":1887794156,"src\/Kafka\/Exception\/NotSupported.php":2083554785,"src\/Kafka\/Exception\/OutOfRange.php":613717588,"src\/Kafka\/Exception\/Protocol.php":2787269416,"src\/Kafka\/Exception\/Socket.php":2743402340,"src\/Kafka\/Exception\/SocketConnect.php":2883015980,"src\/Kafka\/Exception\/SocketEOF.php":1195314501,"src\/Kafka\/Exception\/SocketTimeout.php":1079612001,"src\/Kafka\/Exception\/Config.php":2153825859,"src\/Kafka\/Protocol\/CommitOffset.php":3711823135,"src\/Kafka\/Protocol\/Fetch.php":4166817029,"src\/Kafka\/Protocol\/FetchOffset.php":2615769477,"src\/Kafka\/Protocol\/GroupCoordinator.php":3030713974,"src\/Kafka\/Protocol\/Heartbeat.php":3269486857,"src\/Kafka\/Protocol\/JoinGroup.php":332592611,"src\/Kafka\/Protocol\/Metadata.php":1609652106,"src\/Kafka\/Protocol\/Offset.php":3262177831,"src\/Kafka\/Protocol\/Produce.php":1894065123,"src\/Kafka\/Protocol\/Protocol.php":476565724,"src\/Kafka\/Protocol\/SyncGroup.php":3584049845,"src\/Kafka\/Protocol.php":338507625,"src\/Kafka\/SingletonTrait.php":3424400384,"src\/Kafka\/Socket.php":15705974,"src\/Kafka\/ConsumerConfig.php":2320744655,"src\/Kafka\/ProducerConfig.php":1925922788,"src\/Kafka\/Config.php":913412482,"src\/Kafka\/Broker.php":598094486,"src\/Kafka\/Consumer.php":4050243291,"src\/Kafka\/Consumer\/Assignment.php":626810662,"src\/Kafka\/Consumer\/Process.php":511720065,"src\/Kafka\/Consumer\/State.php":1179310365,"src\/Kafka\/LoggerTrait.php":1234965748,"src\/Kafka\/Producer.php":2558655402,"src\/Kafka\/Producer\/State.php":3349306988,"src\/Kafka\/Producer\/Process.php":485988665,"tests\/KafkaMock\/Protocol\/Encoder.php":1383970351,"tests\/KafkaTest\/ClientTest.php":347003966,"tests\/KafkaTest\/Produce\/ProduceTest.php":868593207,"tests\/KafkaTest\/Protocol\/DecoderTest.php":1953905898,"tests\/KafkaTest\/Protocol\/EncoderTest.php":118406869,"tests\/TestConfiguration.php":1872544484,"tests\/_autoload.php":2725147420,"tests\/run-tests.php":4228663547,"tests\/Bootstrap.php":3397345411,"tests\/KafkaTest\/Protocol\/GroupCoordinatorTest.php":3938006454,"tests\/KafkaTest\/Base\/ProtocolTest.php":3926873193,"tests\/KafkaTest\/Base\/BrokerTest.php":3957314909,"tests\/KafkaTest\/Base\/ConsumerConfigTest.php":901088941,"tests\/KafkaTest\/Base\/ProducerConfigTest.php":1821493122,"tests\/KafkaTest\/Protocol\/ProduceTest.php":3670305798,"tests\/KafkaTest\/Protocol\/OffsetTest.php":3799352786,"tests\/KafkaTest\/Protocol\/FetchTest.php":2392957613,"tests\/KafkaTest\/Protocol\/CommitOffsetTest.php":3999089971,"tests\/KafkaTest\/Protocol\/SyncGroupTest.php":1695142498,"tests\/KafkaTest\/Protocol\/HeartbeatTest.php":3012473440,"tests\/KafkaTest\/Protocol\/FetchOffsetTest.php":1945252662,"tests\/KafkaTest\/Protocol\/MetadataTest.php":1723320331,"tests\/KafkaTest\/Protocol\/JoinGroupTest.php":3735777277,"src\/Kafka\/Protocol\/LeaveGroup.php":3263763308,"src\/Kafka\/Protocol\/ListGroup.php":3673950913,"src\/Kafka\/Protocol\/DescribeGroups.php":1369242879,"tests\/KafkaTest\/Protocol\/LeaveGroupTest.php":1567634470,"tests\/KafkaTest\/Protocol\/DescribeGroupsTest.php":759837642,"tests\/KafkaTest\/Protocol\/ListGroupTest.php":3375737744}}

‎example/Producer.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
$config = \Kafka\ProducerConfig::getInstance();
1212
$config->setMetadataRefreshIntervalMs(10000);
13-
$config->setMetadataBrokerList('10.13.4.159:9192');
14-
$config->setBrokerVersion('0.9.0.1');
13+
$config->setMetadataBrokerList('127.0.0.1:9292');
14+
$config->setBrokerVersion('0.10.0.1');
1515
$config->setRequiredAck(1);
1616
$config->setIsAsyn(false);
1717
$config->setProduceInterval(500);
@@ -20,7 +20,7 @@
2020
array(
2121
'topic' =>'test',
2222
'value' =>'test....message.',
23-
'key' =>'testkey',
23+
'key' =>'',
2424
),
2525
);
2626
});

‎src/Kafka/Producer/Process.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ protected function convertMessage($data)
363363
}
364364

365365
$partition['partition_id'] =$partId;
366-
$partition['messages'][] =array('value' =>$value['value'],'key' =>$value['key']);
366+
if (trim($value['key']) !='') {
367+
$partition['messages'][] =array('value' =>$value['value'],'key' =>$value['key']);
368+
}else {
369+
$partition['messages'][] =$value['value'];
370+
}
367371

368372
$topicData['partitions'][$partId] =$partition;
369373
$topicData['topic_name'] =$value['topic'];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp