1
1
using System ;
2
2
using System . Web ;
3
3
using Grpc . Core ;
4
- using StreamsDB . Wire ;
5
- using WireClient = StreamsDB . Wire . Streams . StreamsClient ;
4
+ using StreamsDB . Driver . Wire ;
5
+ using static StreamsDB . Driver . Wire . Streams ;
6
6
7
- namespace StreamsDB . Client
7
+ namespace StreamsDB . Driver
8
8
{
9
- public class Connection
9
+ public class StreamsDBClient
10
10
{
11
11
private readonly Channel _channel ;
12
- private readonly WireClient _client ;
12
+ private readonly StreamsClient _client ;
13
13
private volatile string _db ;
14
14
private readonly Metadata _metadata = new Metadata ( ) ;
15
15
16
- private Connection ( Channel channel , WireClient client , string defaultDb = null )
17
- {
18
- _channel = channel ;
19
- _client = client ;
20
- _db = defaultDb ;
21
- }
22
-
23
- public static Connection Open ( string connectionString = null )
16
+ public StreamsDBClient ( string connectionString = null )
24
17
{
25
18
if ( string . IsNullOrEmpty ( connectionString ) ) {
26
19
connectionString = Environment . GetEnvironmentVariable ( "SDB_HOST" ) ;
@@ -47,24 +40,25 @@ public static Connection Open(string connectionString = null)
47
40
}
48
41
49
42
var channel = new Channel ( uri . Host , uri . Port , cred ) ;
50
- var client = new WireClient ( channel ) ;
43
+ var apiClient = new StreamsClient ( channel ) ;
51
44
String defaultDb = null ;
52
45
if ( ! string . IsNullOrEmpty ( uri . AbsolutePath ) )
53
46
{
54
47
defaultDb = uri . AbsolutePath . Trim ( '/' ) ;
55
48
}
56
49
57
- var conn = new Connection ( channel , client , defaultDb ) ;
50
+ _channel = channel ;
51
+ _client = apiClient ;
52
+ _db = defaultDb ;
53
+
58
54
if ( ! string . IsNullOrEmpty ( uri . UserInfo ) )
59
55
{
60
56
var items = uri . UserInfo . Split ( new char [ ] { ':' } ) ;
61
- var username = items [ 0 ] ;
62
- var password = items [ 1 ] ;
57
+ var username = HttpUtility . UrlDecode ( items [ 0 ] ) ;
58
+ var password = HttpUtility . UrlDecode ( items [ 1 ] ) ;
63
59
64
- conn . Login ( username , password ) ;
60
+ this . Login ( username , password ) ;
65
61
}
66
-
67
- return conn ;
68
62
}
69
63
70
64
public void Login ( string username , string password )
0 commit comments