Skip to content

Commit

Permalink
Merge pull request #21 from microsoft/philon/merge_ser
Browse files Browse the repository at this point in the history
Merge latest changes from StackExchange.Redis repo
  • Loading branch information
philon-msft authored May 23, 2021
2 parents 370736e + 73a0ff2 commit f2daba9
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 11 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG INSTALL_NODE=false
ARG INSTALL_AZURE_CLI=false
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:dev-5.0

ENV DOTNET_NOLOGO=true
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
ENV DEVCONTAINER=true

# install redis-cli and ping
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends iputils-ping redis-tools mono-runtime

# install SDK 3.1
RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 3.1 --install-dir /usr/share/dotnet/
12 changes: 12 additions & 0 deletions .devcontainer/TestConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"MasterServer": "redis",
"ReplicaServer": "redis",
"SecureServer": "redis",
"FailoverMasterServer": "redis",
"FailoverReplicaServer": "redis",
"RediSearchServer": "redisearch",
"IPv4Server": "redis",
"RemoteServer": "redis",
"SentinelServer": "redis",
"ClusterServer": "redis"
}
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "StackExchange.Redis",
"dockerComposeFile": [
"docker-compose.yml"
],
"service": "devcontainer",
"workspaceFolder": "/workspace",
"postCreateCommand": "dotnet restore Build.csproj",

"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-dotnettools.csharp",
"ms-azuretools.vscode-docker"
],
}
27 changes: 27 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.7'

services:
devcontainer:
build:
context: .
dockerfile: Dockerfile
volumes:
- ..:/workspace:cached
# Mount the TestConfig.json file as readonly, so that tests talk to services in the internal docker network
# This leaves the original TestsConfig.json outside the devcontainer untouched
- ./TestConfig.json:/workspace/tests/StackExchange.Redis.Tests/TestConfig.json:ro
depends_on:
- redis
- redisearch
links:
- "redis:redis"
- "redisearch:redisearch"
command: /bin/sh -c "while sleep 1000; do :; done"
redis:
build:
context: ../tests/RedisConfigs
dockerfile: Dockerfile
sysctls :
net.core.somaxconn: '511'
redisearch:
image: redislabs/redisearch:latest
2 changes: 1 addition & 1 deletion Build.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Build.Traversal/2.0.24">
<Project Sdk="Microsoft.Build.Traversal/3.0.2">
<ItemGroup>
<ProjectReference Include="src\**\*.csproj" />
<ProjectReference Include="tests\**\*.csproj" />
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<IsPackable>true</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" Condition=" '$(DEVCONTAINER)' != 'true' " />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions src/StackExchange.Redis/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ internal void SetBacklogState(int position, PhysicalConnection physical)

// All for profiling purposes
private ProfiledCommand performance;
internal DateTime createdDateTime;
internal long createdTimestamp;
internal DateTime CreatedDateTime;
internal long CreatedTimestamp;

protected Message(int db, CommandFlags flags, RedisCommand command)
{
Expand Down Expand Up @@ -131,8 +131,8 @@ protected Message(int db, CommandFlags flags, RedisCommand command)
Flags = flags & UserSelectableFlags;
if (masterOnly) SetMasterOnly();

createdDateTime = DateTime.UtcNow;
createdTimestamp = System.Diagnostics.Stopwatch.GetTimestamp();
CreatedDateTime = DateTime.UtcNow;
CreatedTimestamp = System.Diagnostics.Stopwatch.GetTimestamp();
Status = CommandStatus.WaitingToBeSent;
}

Expand Down Expand Up @@ -188,8 +188,8 @@ internal void PrepareToResend(ServerEndPoint resendTo, bool isMoved)
oldPerformance.SetCompleted();
performance = null;

createdDateTime = DateTime.UtcNow;
createdTimestamp = System.Diagnostics.Stopwatch.GetTimestamp();
CreatedDateTime = DateTime.UtcNow;
CreatedTimestamp = System.Diagnostics.Stopwatch.GetTimestamp();
performance = ProfiledCommand.NewAttachedToSameContext(oldPerformance, resendTo, isMoved);
performance.SetMessage(this);
Status = CommandStatus.WaitingToBeSent;
Expand Down
4 changes: 2 additions & 2 deletions src/StackExchange.Redis/Profiling/ProfiledCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void SetMessage(Message msg)
if (Message != null) throw new InvalidOperationException($"{nameof(SetMessage)} called more than once");

Message = msg;
MessageCreatedDateTime = msg.createdDateTime;
MessageCreatedTimeStamp = msg.createdTimestamp;
MessageCreatedDateTime = msg.CreatedDateTime;
MessageCreatedTimeStamp = msg.CreatedTimestamp;
}

public void SetEnqueued() => SetTimestamp(ref EnqueuedTimeStamp);
Expand Down
5 changes: 4 additions & 1 deletion src/StackExchange.Redis/RedisValueWithExpiry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ namespace Microsoft.Caching.Redis
/// </summary>
public readonly struct RedisValueWithExpiry
{
internal RedisValueWithExpiry(RedisValue value, TimeSpan? expiry)
/// <summary>
/// Creates a <see cref="RedisValueWithExpiry"/> from a <see cref="RedisValue"/> and a <see cref="Nullable{TimeSpan}"/>
/// </summary>
public RedisValueWithExpiry(RedisValue value, TimeSpan? expiry)
{
Value = value;
Expiry = expiry;
Expand Down

0 comments on commit f2daba9

Please sign in to comment.