Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
78a37102
Commit
78a37102
authored
Jul 23, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
experimental kestrel csproj
parent
fe830a47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
7 deletions
+94
-7
KestrelRedisServer.csproj
KestrelRedisServer/KestrelRedisServer.csproj
+13
-0
Program.cs
KestrelRedisServer/Program.cs
+25
-0
RedisConnectionHandler.cs
KestrelRedisServer/RedisConnectionHandler.cs
+43
-0
RespServer.cs
StackExchange.Redis.Server/RespServer.cs
+6
-6
StackExchange.Redis.sln
StackExchange.Redis.sln
+7
-1
No files found.
KestrelRedisServer/KestrelRedisServer.csproj
0 → 100644
View file @
78a37102
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.2" />
<ProjectReference Include="..\StackExchange.Redis.Server\StackExchange.Redis.Server.csproj" />
</ItemGroup>
</Project>
KestrelRedisServer/Program.cs
0 → 100644
View file @
78a37102
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore.Connections
;
using
Microsoft.AspNetCore.Hosting
;
namespace
KestrelRedisServer
{
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
CreateWebHostBuilder
(
args
).
Build
().
Run
();
}
public
static
IWebHostBuilder
CreateWebHostBuilder
(
string
[]
args
)
=>
WebHost
.
CreateDefaultBuilder
(
args
)
.
UseKestrel
(
options
=>
{
// TCP 6379
options
.
ListenLocalhost
(
8007
,
builder
=>
{
builder
.
UseConnectionHandler
<
RedisConnectionHandler
>();
});
});
}
}
KestrelRedisServer/RedisConnectionHandler.cs
0 → 100644
View file @
78a37102
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Connections
;
using
Microsoft.Extensions.Logging
;
using
StackExchange.Redis.Server
;
namespace
KestrelRedisServer
{
public
class
RedisConnectionHandler
:
ConnectionHandler
{
private
readonly
MemoryCacheRedisServer
_server
;
public
RedisConnectionHandler
(
ILogger
<
RedisConnectionHandler
>
logger
)
{
_server
=
new
MemoryCacheRedisServer
();
}
public
override
async
Task
OnConnectedAsync
(
ConnectionContext
connection
)
{
var
client
=
_server
.
AddClient
();
try
{
while
(
true
)
{
var
read
=
await
connection
.
Transport
.
Input
.
ReadAsync
();
var
buffer
=
read
.
Buffer
;
bool
makingProgress
=
false
;
while
(
_server
.
TryProcessRequest
(
ref
buffer
,
client
,
connection
.
Transport
.
Output
))
{
makingProgress
=
true
;
await
connection
.
Transport
.
Output
.
FlushAsync
();
}
connection
.
Transport
.
Input
.
AdvanceTo
(
buffer
.
Start
,
buffer
.
End
);
if
(!
makingProgress
&&
read
.
IsCompleted
)
break
;
}
}
finally
{
_server
.
RemoveClient
(
client
);
connection
.
Transport
.
Input
.
Complete
();
connection
.
Transport
.
Output
.
Complete
();
}
}
}
}
StackExchange.Redis.Server/RespServer.cs
View file @
78a37102
...
...
@@ -199,22 +199,23 @@ private static void StartOnScheduler(PipeScheduler scheduler, Action<object> cal
}
// for extensibility, so that a subclass can get their own client type
// to be used via ListenForConnections
p
rotected
virtual
RedisClient
CreateClient
()
=>
new
RedisClient
();
p
ublic
virtual
RedisClient
CreateClient
()
=>
new
RedisClient
();
public
int
ClientCount
{
get
{
lock
(
_clients
)
{
return
_clients
.
Count
;
}
}
}
public
int
TotalClientCount
{
get
;
private
set
;
}
public
void
AddClient
(
RedisClient
client
)
public
RedisClient
AddClient
(
)
{
if
(
client
==
null
)
throw
new
ArgumentNullException
(
nameof
(
client
)
);
var
client
=
CreateClient
(
);
lock
(
_clients
)
{
ThrowIfShutdown
();
_clients
.
Add
(
client
);
TotalClientCount
++;
}
return
client
;
}
public
bool
RemoveClient
(
RedisClient
client
)
{
...
...
@@ -234,9 +235,8 @@ private async void ListenForConnections(PipeOptions sendOptions, PipeOptions rec
var
client
=
await
_listener
.
AcceptAsync
();
SocketConnection
.
SetRecommendedServerOptions
(
client
);
var
pipe
=
SocketConnection
.
Create
(
client
,
sendOptions
,
receiveOptions
);
var
c
=
Create
Client
();
var
c
=
Add
Client
();
c
.
LinkedPipe
=
pipe
;
AddClient
(
c
);
StartOnScheduler
(
receiveOptions
.
ReaderScheduler
,
RunClientCallback
,
c
);
}
}
...
...
@@ -410,7 +410,7 @@ public static bool TryParseRequest(ref ReadOnlySequence<byte> buffer, out RedisR
return
false
;
}
bool
TryProcessRequest
(
ref
ReadOnlySequence
<
byte
>
buffer
,
RedisClient
client
,
PipeWriter
output
)
public
bool
TryProcessRequest
(
ref
ReadOnlySequence
<
byte
>
buffer
,
RedisClient
client
,
PipeWriter
output
)
{
if
(!
buffer
.
IsEmpty
&&
TryParseRequest
(
ref
buffer
,
out
var
request
))
{
...
...
StackExchange.Redis.sln
View file @
78a37102
...
...
@@ -79,7 +79,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Failover", "Failover", "{D0
RedisConfigs\Failover\slave-6383.conf = RedisConfigs\Failover\slave-6383.conf
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackExchange.Redis.Server", "StackExchange.Redis.Server\StackExchange.Redis.Server.csproj", "{8375813E-FBAF-4DA3-A2C7-E4645B39B931}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackExchange.Redis.Server", "StackExchange.Redis.Server\StackExchange.Redis.Server.csproj", "{8375813E-FBAF-4DA3-A2C7-E4645B39B931}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KestrelRedisServer", "KestrelRedisServer\KestrelRedisServer.csproj", "{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
...
@@ -123,6 +125,10 @@ Global
{8375813E-FBAF-4DA3-A2C7-E4645B39B931}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8375813E-FBAF-4DA3-A2C7-E4645B39B931}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8375813E-FBAF-4DA3-A2C7-E4645B39B931}.Release|Any CPU.Build.0 = Release|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment