Пример #1
0
        public Partition customPartitioner(string topic, int partitionCount, ReadOnlySpan <byte> keyData, bool keyIsNull)
        {
            var keyString = System.Text.UTF8Encoding.UTF8.GetString(keyData.ToArray());

            _logger.LogInformation("Key string in partitioner : {key}", keyString);
            return(new Partition(_murmurHashUtil.MurmurHash(keyData.ToArray(), partitionCount)));
        }
Пример #2
0
        public string GenerateRequestId(bool computePartition)
        {
            string requestId = Guid.NewGuid().ToString();

            if (computePartition)
            {
                while (!IsAssignmentPartition(_murmurHashUtil.MurmurHash(requestId)))
                {
                    requestId = Guid.NewGuid().ToString();
                }
            }

            return(requestId);
        }