Skip to content

Commit

Permalink
Merge pull request #187 from memphisdev/master
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
idanasulin2706 authored Jan 11, 2024
2 parents 46707e4 + 1fafe73 commit 7b9b7a3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion NUGET-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ client.FetchMessages(new FetchMessageOptions
ConsumerName= "<consumer-name>",
ConsumerGroup= "<group-name>", // defaults to the consumer name.
BatchSize= 10, // defaults to 10
BatchMaxTimeToWaitMs= 100, // defaults to 100
BatchMaxTimeToWaitMs= 1000, // defaults to 1000
MaxAckTimeMs= 30000, // defaults to 30000
MaxMsgDeliveries= 2, // defaults to 2
GenerateUniqueSuffix= false, // defaults to false
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ var memphisClient = await MemphisClientFactory.CreateClient(options);
ConsumerName = "MyConsumer",
PullIntervalMs = 10_000,
BatchSize = 100,
BatchMaxTimeToWaitMs = 100
BatchMaxTimeToWaitMs = 1000
});
}
catch (Exception ex)
Expand All @@ -1010,7 +1010,7 @@ try
ConsumerName = "MyConsumer",
PullIntervalMs = 10_000,
BatchSize = 100,
BatchMaxTimeToWaitMs = 100,
BatchMaxTimeToWaitMs = 1000,
MaxMsgDeliveries = 2
});
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@ client.FetchMessages(new FetchMessageOptions
ConsumerName= "<consumer-name>",
ConsumerGroup= "<group-name>", // defaults to the consumer name.
BatchSize= 10, // defaults to 10
BatchMaxTimeToWaitMs= 100, // defaults to 100
BatchMaxTimeToWaitMs= 1000, // defaults to 1000
MaxAckTimeMs= 30000, // defaults to 30000
MaxMsgDeliveries= 2, // defaults to 2
StartConsumeFromSequence= 1, // start consuming from a specific sequence. defaults to 1
Expand Down
8 changes: 4 additions & 4 deletions src/Memphis.Client/Consumer/FetchMessageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Memphis.Client.Consumer;

public sealed class FetchMessageOptions
{
private int _batchMaxTimeToWaitMs = 100;
private int _batchMaxTimeToWaitMs = 1000;

public string ConsumerName { get; set; }
public string StationName { get; set; }
Expand All @@ -13,13 +13,13 @@ public sealed class FetchMessageOptions

/// <summary>
/// The maximum time to wait for a batch message to be consumed in milliseconds.
/// The default value is 5000 (5 seconds).
/// The lowest value is 1000 (1 second), and if it is set a value lower than 1 second, it will be ignored.
/// The default value is 1000.
/// The lowest value is 1000, and if it is set a value lower than 1000, it will be ignored.
/// </summary>
public int BatchMaxTimeToWaitMs
{
get => _batchMaxTimeToWaitMs;
set =>_batchMaxTimeToWaitMs = (value < 100) ? 100 : value;
set =>_batchMaxTimeToWaitMs = (value < 1000) ? 1000 : value;
}

public int MaxAckTimeMs { get; set; } = 30_000;
Expand Down
8 changes: 4 additions & 4 deletions src/Memphis.Client/Consumer/MemphisConsumerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Memphis.Client.Consumer;

public sealed class MemphisConsumerOptions
{
private int _batchMaxTimeToWaitMs = 100;
private int _batchMaxTimeToWaitMs = 1000;

public string StationName { get; set; }
public string ConsumerName { get; set; }
Expand All @@ -13,13 +13,13 @@ public sealed class MemphisConsumerOptions
public int BatchSize { get; set; } = 10;
/// <summary>
/// The maximum time to wait for a batch message to be consumed in milliseconds.
/// The default value is 5000 (5 seconds).
/// The lowest value is 1000 (1 second), and if it is set a value lower than 1 second, it will be ignored.
/// The default value is 1000.
/// The lowest value is 1000, and if it is set a value lower than 1000, it will be ignored.
/// </summary>
public int BatchMaxTimeToWaitMs
{
get => _batchMaxTimeToWaitMs;
set => _batchMaxTimeToWaitMs = (value < 100) ? 100 : value;
set => _batchMaxTimeToWaitMs = (value < 1000) ? 1000 : value;
}
public int MaxAckTimeMs { get; set; } = 30_000;
public int MaxMsgDeliveries { get; set; } = 2;
Expand Down
28 changes: 13 additions & 15 deletions src/Memphis.Client/Exception/MemphisExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@ namespace Memphis.Client;

public static class MemphisExceptions{

public static readonly MemphisConnectionException DeadConnectionException = new("Connection to the broker is dead");
public static MemphisConnectionException DeadConnectionException => new("Connection to the broker is dead");

public static readonly MemphisConnectionException UnableToDealyDLSException = new("Unable to delay DLS message");
public static MemphisConnectionException UnableToDealyDLSException => new("Unable to delay DLS message");

public static readonly MemphisException EmptySchemaNameException = new("Schema name can not be empty");
public static MemphisException EmptySchemaNameException => new("Schema name can not be empty");

public static readonly MemphisException SchemaNameTooLongException = new("Schema name should be under 128 characters");
public static MemphisException SchemaNameTooLongException => new("Schema name should be under 128 characters");

public static readonly MemphisException InvalidSchemaNameException = new("Only alphanumeric and the '_', '-', '.' characters are allowed in schema name");
public static MemphisException InvalidSchemaNameException => new("Only alphanumeric and the '_', '-', '.' characters are allowed in schema name");

public static readonly MemphisException InvalidSchemaStartEndCharsException = new("Schema name can not start or end with non alphanumeric character");
public static MemphisException InvalidSchemaStartEndCharsException => new("Schema name can not start or end with non alphanumeric character");

public static readonly MemphisException EmptySchemaTypeException = new("Schema type can not be empty");
public static MemphisException EmptySchemaTypeException => new("Schema type can not be empty");

public static readonly MemphisException UnsupportedSchemaTypeException = new("Unsupported schema type, the supported schema types are: json, graphql, protobuf, avro\"");
public static MemphisException UnsupportedSchemaTypeException => new("Unsupported schema type, the supported schema types are: json, graphql, protobuf, avro\"");

public static readonly MemphisException SchemaUpdateSubscriptionFailedException = new("Unable to add subscription of schema updates for station");
public static MemphisException SchemaUpdateSubscriptionFailedException => new("Unable to add subscription of schema updates for station");

public static readonly MemphisException InvalidConnectionTypeException = new("You have to connect with one of the following methods: connection token / password");
public static MemphisException InvalidConnectionTypeException => new("You have to connect with one of the following methods: connection token / password");

public static readonly MemphisException StationUnreachableException = new("Station unreachable");
public static MemphisException StationUnreachableException => new("Station unreachable");

public static readonly MemphisException BothPartitionNumAndKeyException = new("PartitionKey and PartitionNumber can not be set at the same time");
public static MemphisException BothPartitionNumAndKeyException => new("PartitionKey and PartitionNumber can not be set at the same time");

public static readonly MemphisMessageIdException EmptyMessageIDException = new("Message ID cannot be empty");

public static readonly MemphisException UnsupportedOSException = new("Unsupported OS");
public static MemphisMessageIdException EmptyMessageIDException => new("Message ID cannot be empty");

public static MemphisException FailedToConnectException(System.Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ProtoBufEval/RuntimeEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static string OS
OperatingSystem.Windows => "win",
OperatingSystem.Linux => "linux",
OperatingSystem.OSX => "osx",
_ => throw MemphisExceptions.UnsupportedOSException;
_ => throw new Exception("Unsupported OS")
};
}
}
Expand All @@ -91,7 +91,7 @@ private static string Arch
{
Architecture.X64 or Architecture.X86 => "x86",
Architecture.Arm or Architecture.Arm64 => "arm",
_ => throw MemphisExceptions.UnsupportedOSException;
_ => throw new Exception("Unsupported OS architecture")
};
}
}
Expand Down

0 comments on commit 7b9b7a3

Please sign in to comment.