Skip to content

Commit b86c680

Browse files
committed
Refactored FdbNativeCluster.CreateClusterAsync to return just the cluster handler
1 parent 24af7b0 commit b86c680

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

FoundationDB.Client/Fdb.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public static async Task<IFdbCluster> CreateClusterAsync(string clusterFile, Can
455455
return await CreateClusterInternalAsync(clusterFile, cancellationToken).ConfigureAwait(false);
456456
}
457457

458-
internal static Task<FdbCluster> CreateClusterInternalAsync(string clusterFile, CancellationToken cancellationToken)
458+
internal static async Task<FdbCluster> CreateClusterInternalAsync(string clusterFile, CancellationToken cancellationToken)
459459
{
460460
EnsureIsStarted();
461461

@@ -469,7 +469,8 @@ internal static Task<FdbCluster> CreateClusterInternalAsync(string clusterFile,
469469
//TODO: check the path ? (exists, readable, ...)
470470

471471
//TODO: have a way to configure the default IFdbClusterHander !
472-
return FdbNativeCluster.CreateClusterAsync(clusterFile, cancellationToken);
472+
var handler = await FdbNativeCluster.CreateClusterAsync(clusterFile, cancellationToken).ConfigureAwait(false);
473+
return new FdbCluster(handler, clusterFile);
473474
}
474475

475476
#endregion

FoundationDB.Client/Native/FdbNativeCluster.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#region BSD Licence
2-
/* Copyright (c) 2013-2014, Doxense SAS
2+
/* Copyright (c) 2013-2015, Doxense SAS
33
All rights reserved.
44
55
Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@ public FdbNativeCluster(ClusterHandle handle)
4747
m_handle = handle;
4848
}
4949

50-
public static Task<FdbCluster> CreateClusterAsync(string clusterFile, CancellationToken cancellationToken)
50+
public static Task<IFdbClusterHandler> CreateClusterAsync(string clusterFile, CancellationToken cancellationToken)
5151
{
5252
var future = FdbNative.CreateCluster(clusterFile);
5353
return FdbFuture.CreateTaskFromHandle(future,
@@ -60,7 +60,8 @@ public static Task<FdbCluster> CreateClusterAsync(string clusterFile, Cancellati
6060
cluster.Dispose();
6161
throw Fdb.MapToException(err);
6262
}
63-
return new FdbCluster(new FdbNativeCluster(cluster), clusterFile);
63+
var handler = new FdbNativeCluster(cluster);
64+
return (IFdbClusterHandler) handler;
6465
},
6566
cancellationToken
6667
);
@@ -108,7 +109,8 @@ public Task<IFdbDatabaseHandler> OpenDatabaseAsync(string databaseName, Cancella
108109
database.Dispose();
109110
throw Fdb.MapToException(err);
110111
}
111-
return (IFdbDatabaseHandler) new FdbNativeDatabase(database);
112+
var handler = new FdbNativeDatabase(database);
113+
return (IFdbDatabaseHandler) handler;
112114
},
113115
cancellationToken
114116
);

0 commit comments

Comments
 (0)