/// <summary>
        /// Returns a driver for a Neo4j instance with custom configuration.
        /// </summary>
        /// <param name="uri">
        /// The URI to the Neo4j instance. Should be in the form
        /// <c>neo4j://&lt;server location&gt;:&lt;port&gt;</c>.
        /// If <c>port</c> is not supplied the default of <c>7687</c> will be used.</param>
        /// <param name="authToken">Authentication to use, <see cref="AuthTokens" />.</param>
        /// <param name="action">
        /// Defines how to build a driver configuration <see cref="Config"/> using <see cref="ConfigBuilder"/>.
        /// If set to <c>null</c>, then no modification will be carried out on the build.
        /// As a result, a default config with default settings will be used <see cref="Config" /> when creating the new driver.
        /// </param>
        /// <returns>A new driver to the database instance specified by the <paramref name="uri"/>.</returns>
        public static IDriver Driver(Uri uri, IAuthToken authToken, Action <ConfigBuilder> action)
        {
            Throw.ArgumentNullException.IfNull(uri, nameof(uri));
            Throw.ArgumentNullException.IfNull(authToken, nameof(authToken));
            var config = ConfigBuilders.BuildConfig(action);

            var connectionSettings = new ConnectionSettings(uri, authToken, config);
            var bufferSettings     = new BufferSettings(config);
            var connectionFactory  =
                new PooledConnectionFactory(connectionSettings, bufferSettings, config.Logger);

            return(CreateDriver(uri, config, connectionFactory));
        }
Example #2
0
        public IInternalAsyncSession Session(Action <SessionConfigBuilder> action, bool reactive)
        {
            if (IsClosed)
            {
                ThrowDriverClosedException();
            }

            var sessionConfig = ConfigBuilders.BuildSessionConfig(action);

            var session = new AsyncSession(_connectionProvider, _logger, _retryLogic, sessionConfig.DefaultAccessMode,
                                           sessionConfig.Database, Bookmark.From(sessionConfig.Bookmarks ?? Array.Empty <Bookmark>()), reactive,
                                           ParseFetchSize(sessionConfig.FetchSize));

            if (IsClosed)
            {
                ThrowDriverClosedException();
            }

            return(session);
        }