Creates a new Connection instance.

@param {ConnectionContext} context

@returns {Object}
518730
function Connection(context)
{
  // validate input
  Errors.assertInternal(Util.isObject(context));

  var services = context.getServices();
  var connectionConfig = context.getConnectionConfig();

  // generate an id for the connection
  var id = uuidv4();

  /**
   * Returns true if the connection is active otherwise false
   *
   * @returns {boolean}
   */
  this.isUp = function()
  {
    return services.sf.isConnected();
  };

  this.getServiceName = function()
  {
    return services.sf.getServiceName();
  };

  this.getClientSessionKeepAlive = function()
  {
    return services.sf.getClientSessionKeepAlive();
  };

  this.getClientSessionKeepAliveHeartbeatFrequency = function()
  {
    return services.sf.getClientSessionKeepAliveHeartbeatFrequency();
  };

  /**
   * Returns the connection id.
   *
   * @returns {String}
   */
  this.getId = function()
  {
    return id;
  };

  this.heartbeat = function(self)
  {
    self.execute({
      sqlText: 'select /* nodejs:heartbeat */ 1;',
      complete: function () {},
      internal: true,
    });
  };

  /**
   * Establishes a connection if we aren't in a fatal state.
   *
   * @param {Function} callback
   *
   * @returns {Object} the connection object.
   */
  this.connect = function(callback)
  {
    // invalid callback
    Errors.checkArgumentValid(
        !Util.exists(callback) || Util.isFunction(callback),
        ErrorCodes.ERR_CONN_CONNECT_INVALID_CALLBACK);

    // connect to the snowflake service and provide our own callback so that
    // the connection can be passed in when invoking the connection.connect()
    // callback
    var self = this;

    services.sf.connect(
    {
      callback: function(err)
      {
        if (Parameters.getValue(Parameters.names.CLIENT_SESSION_KEEP_ALIVE))
        {
          self.keepalive = setInterval(self.heartbeat, Parameters.getValue(Parameters.names.CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY) * 1000, self);
        }

        if (Util.isFunction(callback))
        {
          callback(Errors.externalize(err), self);
        }
      }
    });

    // return the connection to facilitate chaining
    return this;
  };

  /**
   * Executes a statement.
   *
   * @param {Object} options
   *
   * @returns {Object}
   */
  this.execute = function(options)
  {
    return Statement.createRowStatementPreExec(
        options, services, connectionConfig);
  };

  /**
   * Fetches the result of a previously issued statement.
   *
   * @param {Object} options
   *
   * @returns {Object}
   */
  this.fetchResult = function(options)
  {
    return Statement.createRowStatementPostExec(
        options, services, connectionConfig);
  };

  /**
   * Immediately terminates the connection without waiting for currently
   * executing statements to complete.
   *
   * @param {Function} callback
   *
   * @returns {Object} the connection object.
   */
  this.destroy = function(callback)
  {
    // invalid callback
    Errors.checkArgumentValid(
        !Util.exists(callback) || Util.isFunction(callback),
        ErrorCodes.ERR_CONN_DESTROY_INVALID_CALLBACK);

    // log out of the snowflake service and provide our own callback so that
    // the connection can be passed in when invoking the connection.destroy()
    // callback
    var self = this;
    services.sf.destroy(
    {
      callback: function(err)
      {
        if (Util.exists(self.keepalive))
        {
          clearInterval(self.keepalive);
        }

        if (Util.isFunction(callback))
        {
          callback(Errors.externalize(err), self);
        }
      }
    });

    // return the connection to facilitate chaining
    return this;
  };

  /**
   * Returns a serialized version of this connection.
   *
   * @returns {String}
   */
  this.serialize = function()
  {
    return JSON.stringify(context.getConfig());
  };

  EventEmitter.call(this);
}
661830
function create(context) {
    return {
        CallExpression(node) {
            if (isFunctionDefine(node)) {
                context.report(node, message);
            }
        }
    };
}
390358
function create(context) {
    return {
        CallExpression(node) {
            if (isNamedDefine(node)) {
                context.report(node, message);
            }
        }
    };
}
472187
function ConnectionState(code, stringId, connected) {
  if (arguments.length === 2) {
    connected = stringId;
    stringId = 'NONAME';
  }
  if (!(this instanceof ConnectionState)) {
    return new ConnectionState(code, stringId, connected);
  }

  this.id = stringId;
  this.code = code;
  this.connected = connected;
}
785598
function create(context) {
    const options = Array.isArray(context.options) ? context.options : [];
    const isPathAndPatternsObject =
        typeof options[0] === "object" &&
        (Object.prototype.hasOwnProperty.call(options[0], "paths") ||
            Object.prototype.hasOwnProperty.call(options[0], "patterns"));

    const restrictedPaths =
        (isPathAndPatternsObject ? options[0].paths : options) || [];
    const restrictedPatterns =
        (isPathAndPatternsObject ? options[0].patterns : []) || [];

    const restrictedPathMessages = restrictedPaths.reduce(
        (memo, importName) => {
            if (typeof importName === "string") {
                memo[importName] = null;
            } else {
                memo[importName.name] = importName.message;
            }
            return memo;
        },
        {}
    );

    // if no modules are restricted we don"t need to check
    if (
        Object.keys(restrictedPaths).length === 0 &&
        restrictedPatterns.length === 0
    ) {
        return {};
    }

    const ig = ignore().add(restrictedPatterns);

    /**
     * Report a restricted path.
     * @param {node} node representing the restricted path reference
     * @returns {void}
     * @private
     */
    function reportPath(node) {
        const moduleName = node.value.trim();
        const customMessage = restrictedPathMessages[moduleName];
        const message = customMessage
            ? CUSTOM_MESSAGE_TEMPLATE
            : DEFAULT_MESSAGE_TEMPLATE;

        context.report({
            node,
            message,
            data: {
                moduleName,
                customMessage
            }
        });
    }

    /**
     * Check if the given name is a restricted path name
     * @param {string} name name of a variable
     * @returns {boolean} whether the variable is a restricted path or not
     * @private
     */
    function isRestrictedPath(name) {
        return Object.prototype.hasOwnProperty.call(
            restrictedPathMessages,
            name
        );
    }

    return {
        CallExpression(node) {
            if (!isAmdDefine(node) && !isAmdRequire(node)) return;

            const paths = getDependencyStringNodes(node);

            for (let i = 0; i < paths.length; i++) {
                const nodeCurrent = paths[i];
                const moduleName = nodeCurrent.value.trim();

                // check if argument value is in restricted modules array
                if (isRestrictedPath(moduleName)) {
                    reportPath(nodeCurrent);
                }

                if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) {
                    context.report({
                        node,
                        message:
                            "'{{moduleName}}' module is restricted from being used by a pattern.",
                        data: { moduleName }
                    });
                    break;
                }
            }
        }
    };
}
98555
function create(context) {
    let defineCalls = 0;

    return {
        CallExpression: function (node) {
            if (isDefineCall(node) && ++defineCalls > 1) {
                context.report(node, message);
            }
        }
    };
}
956602
function create(context) {
    return {
        CallExpression(node) {
            if (isRequireCall(node) && ancestor(isConditional, node)) {
                context.report(node, message);
            }
        }
    };
}
1321968
function createAuthKey(context) {
    // Extract the nonces
    var newNonce = utility.string2Buffer(context.newNonce, 32);
    var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
    // Create the serverSalt
    var serverSalt = utility.xor(newNonce.slice(0, 8), serverNonce.slice(0, 8));
    if (logger.isDebugEnabled()) {
        logger.debug('serverSalt(%s) = %s', serverSalt.length, serverSalt.toString('hex'));
    }
    // 
    var authKey = new AuthKey(context.authKeyID, context.authKeyValue);
    if (logger.isDebugEnabled()) {
        logger.debug('authKey = %s', authKey.toString());
    }
    return {
        key: authKey,
        serverSalt: serverSalt,
        toPrintable: tl.utility.toPrintable
    };
}
1107279
async def create_connection(
    host,
    port,
    *,
    loop=None,
    secure=True,
    ssl_context=None,
    **kwargs,
):
    
    loop = loop or asyncio.get_event_loop()

    secure = True if port == 443 else secure
    connection = HTTP2ClientConnection(host, loop=loop, secure=secure)
    if not isinstance(ssl_context, SSLContext):
        ssl_context = default_ssl_context()

    await loop.create_connection(
        lambda: connection,
        host=host,
        port=port,
        ssl=ssl_context,
    )

    return connection
770704
def connection_from_context(self, request_context):
        
        scheme = request_context['scheme'].lower()
        pool_key_constructor = self.key_fn_by_scheme[scheme]
        pool_key = pool_key_constructor(request_context)

        return self.connection_from_pool_key(pool_key, request_context=request_context)
538401
def new_connection
      Connection.new(Backburner.configuration.beanstalk_url) { |conn| Backburner::Hooks.invoke_hook_events(self, :on_reconnect, conn) }
    end
1163346
function create(context) {
    return {
        AssignmentExpression(node) {
            if (assignsToModuleExports(node) && ancestor(isCommonJsWrapper, node)) {
                context.report(node, message);
            }
        }
    };
}
695272
function(contexts) {

        if ( typeof(contexts) == 'undefined' ) {
            var contexts = {
                paths : {}
            }
        }

        self.contexts = contexts;

        if ( typeof(ContextHelper.initialized) != 'undefined' && ContextHelper.instance) {
            self = ContextHelper.instance;
        } else {
            ContextHelper.initialized = true;
            ContextHelper.instance = self
        }



        return self
    }
1133652
function Connection(opts) {

    EventEmitter.call(this);

    opts = opts || {};

    _.defaults(opts, {
        host: 'localhost',
        port: '11211',
        reconnect: true,
        maxValueSize: 1048576
    });

    this.host = opts.host;
    this.port = opts.port;

    this.commandBuffer = new Immutable.List();

    if (opts.onConnect) {
        this.onConnect = opts.onConnect;
    }

    if (opts.onError) {
        this.onError = opts.onError;
    } else {
        this.onError = function onError(err) { this.emit('error'); console.error(err); };
    }
    this.bufferBeforeError = opts.bufferBeforeError;
    this.netTimeout = opts.netTimeout || 500;
    this.backoffLimit = opts.backoffLimit || 10000;
    this.reconnect = opts.reconnect;
    this.disconnecting = false;
    this.ready = false;
    this.backoff = opts.backoff || 10;
    this.maxValueSize = opts.maxValueSize;
    this.writeBuffer = new Immutable.List();

    this.connect();
}
743348
function Client(opts) {
    if (!(this instanceof Client)) {
        return new Client(opts);
    }

    var options = {};

    // If single connection provided, array-ify it
    if (typeof opts === 'string') {
        options.hosts = [opts];
        opts = options;
    } else if (typeof opts === 'undefined') {
        opts = {};
    } else if (_.isArray(opts)) {
        options.hosts = opts;
        opts = options;
    }

    _.defaults(opts, {
        autodiscover: false,
        bufferBeforeError: 1000,
        disabled: false,
        hosts: null,
        reconnect: true,
        onNetError: function onNetError(err) { console.error(err); },
        queue: true,
        netTimeout: 500,
        backoffLimit: 10000,
        maxValueSize: 1048576
    });

    // Iterate over options, assign each to this object
    R.keys(opts).forEach(function(key) {
        this[key] = opts[key];
    }, this);

    if (this.queue) {
        this.buffer = new Immutable.List();
    }

    debug('Connect options', opts);
    this.connect();
}
252416
function create(context) {
    return {
        ReturnStatement(node) {
            if (isCommonJsWrapper(nearestFunction(node).parent)) {
                context.report(node, message);
            }
        }
    };
}
266989
async def create_connection(self):
        ''''''
        connector = self.proxy or self.loop
        return await connector.create_connection(
            self.session_factory, self.host, self.port, **self.kwargs)