idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
56,200
public static function loadConfig ( $ paths ) { $ apaths = explode ( ';' , $ paths ) ; foreach ( $ apaths as $ path ) { if ( is_file ( $ p = realpath ( $ path ) ) ) { $ ext = strtolower ( pathinfo ( $ p , PATHINFO_EXTENSION ) ) ; if ( $ ext === 'conf' ) { return Daemon :: $ config -> loadFile ( $ p ) ; } else { Daemon ...
Load config - file
56,201
public static function getStateOfWorkers ( ) { $ offset = 0 ; $ stat = [ 'idle' => 0 , 'busy' => 0 , 'alive' => 0 , 'shutdown' => 0 , 'preinit' => 0 , 'init' => 0 , 'reloading' => 0 , ] ; $ readed = 0 ; while ( ( $ buf = Daemon :: $ shm_wstate -> read ( $ readed , 1024 ) ) !== false ) { $ buflen = mb_orig_strlen ( $ bu...
Get state of workers .
56,202
public static function log ( ... $ args ) { if ( sizeof ( $ args ) === 1 ) { $ msg = is_scalar ( $ args [ 0 ] ) ? $ args [ 0 ] : Debug :: dump ( $ args [ 0 ] ) ; } else { $ msg = Debug :: dump ( $ args ) ; } $ mt = explode ( ' ' , microtime ( ) ) ; if ( is_resource ( STDERR ) ) { fwrite ( STDERR , '[PHPD] ' . $ msg . "...
Send message to the log
56,203
public static function spawnMaster ( ) { Daemon :: $ masters -> push ( $ thread = new Thread \ Master ) ; $ thread -> start ( ) ; if ( - 1 === $ thread -> getPid ( ) ) { Daemon :: log ( 'could not start master' ) ; exit ( 0 ) ; } return $ thread -> getPid ( ) ; }
Spawn a master process
56,204
public function arrayToHash ( $ array ) { $ hash = [ ] ; for ( $ i = 0 , $ s = sizeof ( $ array ) - 1 ; $ i < $ s ; ++ $ i ) { $ hash [ $ array [ $ i ] ] = $ array [ ++ $ i ] ; } return $ hash ; }
Converts array into hash
56,205
public function autoscan ( $ cmd , $ args = [ ] , $ cbEnd = null , $ limit = null ) { return new AutoScan ( $ this , $ cmd , $ args , $ cbEnd , $ limit ) ; }
Wrapper for scans commands
56,206
public function setRedis ( \ PHPDaemon \ Clients \ Redis \ Pool $ redis ) { $ this -> redis = $ redis ; return $ this ; }
Set Redis instance
56,207
public function beginRequest ( $ req , $ upstream ) { $ e = array_map ( 'rawurldecode' , explode ( '/' , $ req -> attrs -> server [ 'DOCUMENT_URI' ] ) ) ; $ serverId = null ; $ sessId = null ; $ path = null ; $ extra = [ ] ; do { foreach ( $ this -> wss as $ wss ) { $ try = implode ( '/' , $ e ) ; if ( $ try === '' ) {...
Creates Request .
56,208
protected function getConfigDefaults ( ) { return [ 'redis-name' => '' , 'redis-prefix' => 'sockjs:' , 'wss-name' => '' , 'batch-delay' => new \ PHPDaemon \ Config \ Entry \ Double ( '0.05' ) , 'heartbeat-interval' => new \ PHPDaemon \ Config \ Entry \ Double ( '25' ) , 'dead-session-timeout' => new \ PHPDaemon \ Confi...
Setting default config options
56,209
public function onFinish ( ) { parent :: onFinish ( ) ; $ this -> event ( 'disconnect' ) ; if ( isset ( $ this -> xml ) ) { $ this -> xml -> finish ( ) ; } unset ( $ this -> roster ) ; if ( $ this -> keepaliveTimer ) { Timer :: remove ( $ this -> keepaliveTimer ) ; } }
Called when session finishes
56,210
public static function convertFlags ( $ mode , $ text = false ) { $ plus = mb_orig_strpos ( $ mode , '+' ) !== false ; $ sync = mb_orig_strpos ( $ mode , 's' ) !== false ; $ type = strtr ( $ mode , [ 'b' => '' , '+' => '' , 's' => '' , '!' => '' ] ) ; if ( $ text ) { return $ type ; } $ types = [ 'r' => $ plus ? EIO_O_...
Converts string of flags to integer or standard text representation
56,211
public function truncate ( $ offset = 0 , $ cb = null , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! $ this -> fd || $ this -> fd === - 1 ) { if ( $ cb ) { $ cb ( $ this , false ) ; } return false ; } if ( ! FileSystem :: $ supported ) { $ fp = fopen ( $ this -> path , 'r+' ) ; $ r ...
Truncates this file
56,212
public function write ( $ data , $ cb = null , $ offset = null , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! $ this -> fd ) { if ( $ cb ) { $ cb ( $ this , false ) ; } return false ; } if ( $ data === '' ) { if ( $ cb ) { $ cb ( $ this , 0 ) ; } return false ; } if ( ! FileSystem :...
Writes data to file
56,213
public function chown ( $ uid , $ gid = - 1 , $ cb = null , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! $ this -> fd ) { if ( $ cb ) { $ cb ( $ this , false ) ; } return false ; } if ( ! FileSystem :: $ supported ) { $ r = chown ( $ this -> path , $ uid ) ; if ( $ gid !== - 1 ) { $...
Changes ownership of this file
56,214
public function read ( $ length , $ offset = null , $ cb = null , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! $ this -> fd ) { if ( $ cb ) { $ cb ( $ this , false ) ; } return false ; } if ( ! FileSystem :: $ supported ) { if ( $ offset !== null ) { fseek ( $ this -> fd , $ length ...
Reads data from file
56,215
protected function readAllGenHandler ( $ cb , $ size , & $ offset , & $ pri , & $ buf ) { return function ( $ file , $ data ) use ( $ cb , $ size , & $ offset , & $ pri , & $ buf ) { $ buf .= $ data ; $ offset += mb_orig_strlen ( $ data ) ; $ len = min ( $ file -> chunkSize , $ size - $ offset ) ; if ( $ offset >= $ si...
Generates closure - callback for readAll
56,216
protected function readAllChunkedGenHandler ( $ cb , $ chunkcb , $ size , & $ offset , $ pri ) { return function ( $ file , $ data ) use ( $ cb , $ chunkcb , $ size , & $ offset , $ pri ) { $ chunkcb ( $ file , $ data ) ; $ offset += mb_orig_strlen ( $ data ) ; $ len = min ( $ file -> chunkSize , $ size - $ offset ) ; ...
Generates closure - callback for readAllChunked
56,217
public function seek ( $ offset , $ cb , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! \ EIO :: $ supported ) { fseek ( $ this -> fd , $ offset ) ; return false ; } return eio_seek ( $ this -> fd , $ offset , $ pri , $ cb , $ this ) ; }
Move pointer to arbitrary position
56,218
protected function newRequest ( ) { $ req = new \ stdClass ; $ req -> attrs = new \ stdClass ( ) ; $ req -> attrs -> request = [ ] ; $ req -> attrs -> get = [ ] ; $ req -> attrs -> post = [ ] ; $ req -> attrs -> cookie = [ ] ; $ req -> attrs -> server = [ ] ; $ req -> attrs -> files = [ ] ; $ req -> attrs -> session = ...
Creates new Request object
56,219
protected function httpProcessHeaders ( ) { $ this -> req -> attrs -> paramsDone = true ; if ( isset ( $ this -> req -> attrs -> server [ 'HTTP_CONNECTION' ] ) && preg_match ( '~(?:^|\W)Upgrade(?:\W|$)~i' , $ this -> req -> attrs -> server [ 'HTTP_CONNECTION' ] ) && isset ( $ this -> req -> attrs -> server [ 'HTTP_UPGR...
Process HTTP headers
56,220
public function freeRequest ( $ req ) { if ( $ this -> state !== self :: STATE_PROCESSING ) { $ this -> freedBeforeProcessing = true ; return ; } $ req -> attrs -> input = null ; $ this -> req = null ; $ this -> state = self :: STATE_ROOT ; $ this -> unfreezeInput ( ) ; }
Frees this request
56,221
public function onFinish ( ) { Timer :: remove ( $ this -> keepaliveTimer ) ; if ( $ this -> req !== null && $ this -> req instanceof Generic ) { if ( ! $ this -> req -> isFinished ( ) ) { $ this -> req -> abort ( ) ; } } $ this -> req = null ; }
Called when connection is finished
56,222
public function badRequest ( $ req ) { $ this -> state = self :: STATE_ROOT ; $ this -> write ( "400 Bad Request\r\n\r\n<html><head><title>400 Bad Request</title></head><body bgcolor=\"white\"><center><h1>400 Bad Request</h1></center></body></html>" ) ; $ this -> finish ( ) ; }
Send Bad request
56,223
public function executeOne ( ... $ args ) { if ( $ this -> isEmpty ( ) ) { return false ; } $ cb = $ this -> shift ( ) ; if ( $ cb ) { $ cb ( ... $ args ) ; if ( $ cb instanceof CallbackWrapper ) { $ cb -> cancel ( ) ; } } return true ; }
Executes one callback from the top with given arguments
56,224
public function executeAndKeepOne ( ... $ args ) { if ( $ this -> isEmpty ( ) ) { return false ; } $ cb = $ this -> shift ( ) ; $ this -> unshift ( $ cb ) ; if ( $ cb ) { $ cb ( ... $ args ) ; } return true ; }
Executes one callback from the top with given arguments without taking it out
56,225
public function executeAll ( ... $ args ) { if ( $ this -> isEmpty ( ) ) { return 0 ; } $ n = 0 ; do { if ( $ cb = $ this -> shift ( ) ) { $ cb ( ... $ args ) ; ++ $ n ; if ( $ cb instanceof CallbackWrapper ) { $ cb -> cancel ( ) ; } } } while ( ! $ this -> isEmpty ( ) ) ; return $ n ; }
Executes all callbacks with given arguments
56,226
public static function hash ( $ str , $ salt = '' , $ plain = false ) { $ size = 512 ; $ rounds = 1 ; if ( strncmp ( $ salt , '$' , 1 ) === 0 ) { $ e = explode ( '$' , $ salt , 3 ) ; $ ee = explode ( '=' , $ e [ 1 ] ) ; if ( ctype_digit ( $ ee [ 0 ] ) ) { $ size = ( int ) $ e [ 1 ] ; } if ( isset ( $ ee [ 1 ] ) && ctyp...
Generate keccak hash for string with salt
56,227
public static function randomString ( $ len = null , $ chars = null , $ cb = null , $ pri = 0 , $ hang = false ) { if ( $ len === null ) { $ len = 64 ; } if ( $ chars === null ) { $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.' ; } if ( $ cb === null ) { Daemon :: log ( '[CODE WARN] \\PHPD...
Returns string of pseudo random characters
56,228
public static function randomBytes ( $ len , $ cb , $ pri = 0 , $ hang = false ) { $ cb = CallbackWrapper :: wrap ( $ cb ) ; FileSystem :: open ( '/dev/' . ( $ hang ? '' : 'u' ) . 'random' , 'r' , function ( $ file ) use ( $ len , $ cb , $ pri ) { if ( ! $ file ) { $ cb ( false ) ; return ; } $ file -> read ( $ len , 0...
Returns string of pseudo random bytes
56,229
public static function randomInts ( $ numInts , $ cb , $ pri = 0 , $ hang = false ) { static :: randomBytes ( PHP_INT_SIZE * $ numInts , function ( $ bytes ) use ( $ cb , $ numInts ) { if ( $ bytes === false ) { $ cb ( false ) ; return ; } $ ints = [ ] ; for ( $ i = 0 ; $ i < $ numInts ; ++ $ i ) { $ thisInt = 0 ; for ...
Returns array of pseudo random integers of machine - dependent size
56,230
public static function randomInts32 ( $ numInts , $ cb , $ pri = 0 , $ hang = false ) { static :: randomBytes ( 4 * $ numInts , function ( $ bytes ) use ( $ cb , $ numInts ) { if ( $ bytes === false ) { $ cb ( false ) ; return ; } $ ints = [ ] ; for ( $ i = 0 ; $ i < $ numInts ; ++ $ i ) { $ thisInt = 0 ; for ( $ j = 0...
Returns array of pseudo random 32 - bit integers
56,231
public function getFrameType ( $ type ) { if ( is_int ( $ type ) ) { return $ type ; } if ( $ type === null ) { $ type = 'STRING' ; } $ frametype = @ constant ( get_class ( $ this ) . '::' . $ type ) ; if ( $ frametype === null ) { Daemon :: log ( __METHOD__ . ' : Undefined frametype "' . $ type . '"' ) ; } return $ fr...
Get real frame type identificator
56,232
public function onInheritanceFromRequest ( $ req ) { $ this -> state = self :: STATE_HEADERS ; $ this -> addr = $ req -> attrs -> server [ 'REMOTE_ADDR' ] ; $ this -> server = $ req -> attrs -> server ; $ this -> get = $ req -> attrs -> get ; $ this -> prependInput ( "\r\n" ) ; $ this -> onRead ( ) ; }
Called when connection is inherited from HTTP request
56,233
public function onFinish ( ) { $ this -> sendFrame ( '' , 'CONNCLOSE' ) ; if ( $ this -> route ) { $ this -> route -> onFinish ( ) ; } $ this -> route = null ; }
Event of Connection .
56,234
public function gracefulShutdown ( ) { if ( ( ! $ this -> route ) || $ this -> route -> gracefulShutdown ( ) ) { $ this -> finish ( ) ; return true ; } return false ; }
Called when the worker is going to shutdown .
56,235
public function handshake ( ) { $ this -> route = $ this -> pool -> getRoute ( $ this -> server [ 'DOCUMENT_URI' ] , $ this ) ; if ( ! $ this -> route ) { Daemon :: $ process -> log ( get_class ( $ this ) . '::' . __METHOD__ . ' : Cannot handshake session for client "' . $ this -> addr . '"' ) ; $ this -> finish ( ) ; ...
Called when we re going to handshake .
56,236
protected function httpReadHeaders ( ) { while ( ( $ l = $ this -> readLine ( ) ) !== null ) { if ( $ l === '' ) { return true ; } $ e = explode ( ': ' , $ l ) ; if ( isset ( $ e [ 1 ] ) ) { $ this -> currentHeader = 'HTTP_' . strtoupper ( strtr ( $ e [ 0 ] , Generic :: $ htr ) ) ; $ this -> server [ $ this -> currentH...
Read headers line - by - line
56,237
public function header ( $ s , $ replace = true , $ code = false ) { if ( $ code ) { $ this -> status ( $ code ) ; } if ( $ this -> headers_sent ) { throw new RequestHeadersAlreadySent ; } $ s = strtr ( $ s , "\r\n" , ' ' ) ; $ e = explode ( ':' , $ s , 2 ) ; if ( ! isset ( $ e [ 1 ] ) ) { $ e [ 0 ] = 'STATUS' ; if ( ...
Send the header
56,238
protected function checkIfAllReady ( ) { $ this -> checkQueue ( ) ; if ( $ this -> resultsNum >= $ this -> jobsNum ) { $ this -> jobs = [ ] ; $ this -> state = self :: STATE_DONE ; foreach ( $ this -> listeners as $ cb ) { $ cb ( $ this ) ; } if ( ! $ this -> keep && $ this -> resultsNum >= $ this -> jobsNum ) { $ this...
Checks if all jobs are ready
56,239
public function checkQueue ( ) { if ( $ this -> backlog !== null ) { while ( ! $ this -> backlog -> isEmpty ( ) ) { if ( $ this -> maxConcurrency !== - 1 && ( $ this -> jobsNum - $ this -> resultsNum > $ this -> maxConcurrency ) ) { return ; } list ( $ name , $ cb ) = $ this -> backlog -> shift ( ) ; $ this -> addJob (...
Called automatically . Checks whether if the queue is full . If not tries to pull more jobs from backlog and more
56,240
public function more ( $ cb = null ) { if ( $ cb !== null ) { $ this -> more = $ cb ; $ this -> moreFirstFlag = true ; return $ this ; } if ( $ this -> more !== null ) { if ( $ this -> more instanceof \ Iterator ) { iterator : $ it = $ this -> more ; while ( ! $ this -> isQueueFull ( ) && $ it -> valid ( ) ) { if ( $ t...
Sets a callback which is going to be fired always when we have a room for more jobs
56,241
public function execute ( ) { if ( $ this -> state === self :: STATE_WAITING ) { $ this -> state = self :: STATE_RUNNING ; foreach ( $ this -> jobs as $ name => $ cb ) { $ cb ( $ name , $ this ) ; $ this -> jobs [ $ name ] = null ; } $ this -> checkIfAllReady ( ) ; } }
Runs the job
56,242
private function parseShortString ( ) { $ length = \ ord ( $ this -> buffer ) ; try { return mb_orig_substr ( $ this -> buffer , 1 , $ length ) ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , $ length + 1 ) ; } }
Parse an AMQP short string from the head of the buffer .
56,243
private function parseLongString ( ) { list ( , $ length ) = \ unpack ( 'N' , $ this -> buffer ) ; try { return mb_orig_substr ( $ this -> buffer , 4 , $ length ) ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , $ length + 4 ) ; } }
Parse an AMQP long string from the head of the buffer .
56,244
private function parseSignedInt8 ( ) { try { $ result = \ ord ( $ this -> buffer ) ; if ( $ result & 0x80 ) { return $ result - 0x100 ; } return $ result ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , 1 ) ; } }
Parse a 8 - bit signed integer from the head of the buffer .
56,245
private function parseSignedInt16 ( ) { try { $ result = \ unpack ( 'n' , $ this -> buffer ) [ 1 ] ; if ( $ result & 0x8000 ) { return $ result - 0x10000 ; } return $ result ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , 2 ) ; } }
Parse a 16 - bit signed integer from the head of the buffer .
56,246
private function parseSignedInt32 ( ) { try { $ result = \ unpack ( 'N' , $ this -> buffer ) [ 1 ] ; if ( $ result & 0x80000000 ) { return $ result - 0x100000000 ; } return $ result ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , 4 ) ; } }
Parse a 32 - bit signed integer from the head of the buffer .
56,247
private function parseUnsignedInt64 ( ) { try { $ result = \ unpack ( 'J' , $ this -> buffer ) [ 1 ] ; if ( $ result < 0 ) { return sprintf ( '%u' , $ result ) ; } return $ result ; } finally { $ this -> buffer = mb_orig_substr ( $ this -> buffer , 8 ) ; } }
Parse a 64 - bit unsigned integer from the head of the buffer .
56,248
public function getAuthToken ( $ scramble , $ password ) { return sha1 ( $ scramble . sha1 ( $ hash1 = sha1 ( $ password , true ) , true ) , true ) ^ $ hash1 ; }
Generates auth . token
56,249
public function auth ( ) { if ( $ this -> phase !== self :: PHASE_GOT_INIT ) { return ; } $ this -> phase = self :: PHASE_AUTH_SENT ; $ this -> onResponse -> push ( function ( $ conn , $ result ) { if ( $ conn -> onConnected ) { $ conn -> connected = true ; $ conn -> onConnected -> executeAll ( $ conn , $ result ) ; $ ...
Sends auth . packet
56,250
public function query ( $ q , $ cb = null ) { if ( $ this -> finished ) { throw new ConnectionFinished ; } return $ this -> command ( Pool :: COM_QUERY , $ q , $ cb ) ; }
Sends SQL - query
56,251
public function selectDB ( $ name ) { $ this -> dbname = $ name ; if ( $ this -> phase !== self :: PHASE_GOT_INIT ) { return $ this -> query ( 'USE `' . $ name . '`' ) ; } return true ; }
Sets default database name
56,252
protected function overrideNativeFuncs ( ) { if ( Daemon :: supported ( Daemon :: SUPPORT_RUNKIT_INTERNAL_MODIFY ) ) { function define ( $ k , $ v ) { if ( defined ( $ k ) ) { runkit_constant_redefine ( $ k , $ v ) ; } else { runkit_constant_add ( $ k , $ v ) ; } } $ this -> override ( 'define' , 'define' ) ; function ...
Overrides native PHP functions .
56,253
protected function breakMainLoopCheck ( ) { $ time = microtime ( true ) ; if ( $ this -> terminated || $ this -> breakMainLoop ) { EventLoop :: $ instance -> stop ( ) ; return ; } if ( $ this -> shutdown ) { EventLoop :: $ instance -> stop ( ) ; return ; } if ( $ this -> reload ) { return ; } if ( Daemon :: $ config ->...
Check if we should break main loop
56,254
protected function shutdown ( $ hard = false ) { $ error = error_get_last ( ) ; if ( $ error ) { if ( $ error [ 'type' ] === E_ERROR ) { Daemon :: log ( 'W#' . $ this -> pid . ' crashed by error \'' . $ error [ 'message' ] . '\' at ' . $ error [ 'file' ] . ':' . $ error [ 'line' ] ) ; } } if ( Daemon :: $ config -> thr...
Shutdown this worker
56,255
public function setState ( $ int ) { if ( Daemon :: $ compatMode ) { return true ; } if ( ! $ this -> id ) { return false ; } if ( Daemon :: $ config -> logworkersetstate -> value ) { $ this -> log ( 'state is ' . Daemon :: $ wstateRev [ $ int ] ) ; } $ this -> state = $ int ; if ( $ this -> reload ) { $ int += 100 ; }...
Set current status of worker
56,256
protected function run ( ) { Daemon :: $ process = $ this ; $ this -> prepareSystemEnv ( ) ; class_exists ( 'Timer' ) ; gc_enable ( ) ; $ this -> callbacks = new StackCallbacks ; if ( EventLoop :: $ instance ) { $ this -> registerEventSignals ( ) ; } else { $ this -> registerSignals ( ) ; } $ this -> workers = new Coll...
Runtime of Master process
56,257
public function reloadWorker ( $ id ) { if ( isset ( $ this -> workers -> threads [ $ id ] ) ) { if ( ! $ this -> workers -> threads [ $ id ] -> reloaded ) { Daemon :: $ process -> log ( 'Spawning worker-replacer for reloaded worker #' . $ id ) ; $ this -> spawnWorkers ( 1 ) ; $ this -> workers -> threads [ $ id ] -> r...
Reload worker by internal id
56,258
protected function spawnWorkers ( $ n ) { if ( FileSystem :: $ supported ) { eio_event_loop ( ) ; } $ n = ( int ) $ n ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ thread = new Worker ; $ this -> workers -> push ( $ thread ) ; $ this -> callbacks -> push ( function ( $ self ) use ( $ thread ) { $ thread -> start ( ) ; $ p...
Spawn new worker processes
56,259
protected function spawnIPCThread ( ) { if ( FileSystem :: $ supported ) { eio_event_loop ( ) ; } $ thread = new IPC ; $ this -> ipcthreads -> push ( $ thread ) ; $ this -> callbacks -> push ( function ( $ self ) use ( $ thread ) { $ thread -> start ( ) ; $ pid = $ thread -> getPid ( ) ; if ( $ pid < 0 ) { Daemon :: $ ...
Spawn IPC process
56,260
protected function stopWorkers ( $ n = 1 ) { Daemon :: log ( '--' . $ n . '-- ' . Debug :: backtrace ( ) . '-----' ) ; $ n = ( int ) $ n ; $ i = 0 ; foreach ( $ this -> workers -> threads as & $ w ) { if ( $ i >= $ n ) { break ; } if ( $ w -> shutdown ) { continue ; } if ( $ w -> reloaded ) { continue ; } $ w -> stop (...
Stop the workers
56,261
protected function shutdown ( $ signo = false ) { $ this -> shutdown = true ; $ this -> waitAll ( true ) ; Daemon :: $ shm_wstate -> delete ( ) ; file_put_contents ( Daemon :: $ config -> pidfile -> value , '' ) ; posix_kill ( getmypid ( ) , SIGKILL ) ; exit ( 0 ) ; }
Called when master is going to shutdown
56,262
protected function sigquit ( ) { if ( Daemon :: $ config -> logsignals -> value ) { $ this -> log ( 'Caught SIGQUIT.' ) ; } $ this -> signalToChildren ( SIGQUIT ) ; $ this -> shutdown ( SIGQUIT ) ; }
Handler for the SIGQUIT signal in master process
56,263
public static function getInstance ( $ arg = '' , $ spawn = true ) { if ( $ arg === 'default' ) { $ arg = '' ; } $ class = static :: class ; if ( is_string ( $ arg ) ) { $ key = $ class . ':' . $ arg ; if ( isset ( self :: $ instances [ $ key ] ) ) { return self :: $ instances [ $ key ] ; } elseif ( ! $ spawn ) { retur...
Returns instance object
56,264
public function connect ( $ url , $ cb , $ class = null ) { if ( $ class === null ) { $ class = $ this -> connectionClass ; } $ conn = new $ class ( null , $ this ) ; $ conn -> connect ( $ url , $ cb ) ; return $ conn ; }
Establish a connection with remote peer
56,265
public function close ( ) { $ outputFrame = ProtocolChannel \ ChannelCloseFrame :: create ( 0 , 'Channel closed by client' ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection -> command ( $ outputFrame ) ; }
Close the channel .
56,266
public function purgeQueue ( $ name , array $ options = [ ] , callable $ callback = null ) { $ noWait = array_key_exists ( 'noWait' , $ options ) ? ( bool ) $ options [ 'noWait' ] : null ; $ outputFrame = Queue \ QueuePurgeFrame :: create ( $ name , $ noWait ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -...
Purge queue messages
56,267
public function bindQueue ( $ name , $ exchangeName , $ routingKey , array $ options = [ ] , callable $ callback = null ) { $ noWait = array_key_exists ( 'noWait' , $ options ) ? ( bool ) $ options [ 'noWait' ] : null ; $ arguments = array_key_exists ( 'arguments' , $ options ) ? $ options [ 'arguments' ] : null ; $ ou...
Bind queue to exchange
56,268
public function unbindQueue ( $ name , $ exchangeName , $ routingKey , callable $ callback = null ) { $ outputFrame = Queue \ QueueUnbindFrame :: create ( $ name , $ exchangeName , $ routingKey ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection -> command ( $ outputFrame ) ; if ( is_callable ( $ ...
Unbind queue from exchange
56,269
public function consume ( $ queueName , array $ options = [ ] , callable $ callback ) { $ consumerTag = array_key_exists ( 'consumerTag' , $ options ) ? $ options [ 'consumerTag' ] : null ; $ noLocal = array_key_exists ( 'noLocal' , $ options ) ? ( bool ) $ options [ 'noLocal' ] : null ; $ noAck = array_key_exists ( 'n...
Bind a consumer to consume on message receive
56,270
public function get ( $ queueName , array $ options = [ ] , callable $ callback = null ) { $ noAck = array_key_exists ( 'noAck' , $ options ) ? $ options [ 'noAck' ] : null ; $ outputFrame = Basic \ BasicGetFrame :: create ( $ queueName , $ noAck ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection...
get message from queue
56,271
public function ack ( $ deliveryTag , array $ options = [ ] ) { $ multiple = array_key_exists ( 'multiple' , $ options ) ? ( int ) $ options [ 'multiple' ] : null ; $ outputFrame = Basic \ BasicAckFrame :: create ( $ deliveryTag , $ multiple ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection -> c...
Ack message by delivery tag
56,272
public function reject ( $ deliveryTag , array $ options = [ ] ) { $ requeue = array_key_exists ( 'requeue' , $ options ) ? $ options [ 'requeue' ] : null ; $ outputFrame = Basic \ BasicRejectFrame :: create ( $ deliveryTag , $ requeue ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection -> command...
Reject a message
56,273
public function recover ( $ requeue = true ) { $ outputFrame = Basic \ BasicRecoverFrame :: create ( $ requeue ) ; $ outputFrame -> frameChannelId = $ this -> id ; $ this -> connection -> command ( $ outputFrame ) ; }
Redeliver unacknowledged messages .
56,274
public function ack ( ) { $ this -> checkChannel ( ) ; $ outputFrame = BasicAckFrame :: create ( $ this -> tag ) ; $ outputFrame -> frameChannelId = $ this -> channel -> getId ( ) ; $ this -> channel -> getConnection ( ) -> command ( $ outputFrame ) ; }
Acknowledge the message .
56,275
public function nack ( $ multiple = null , $ requeue = null ) { $ this -> checkChannel ( ) ; $ outputFrame = BasicNackFrame :: create ( $ this -> tag , $ multiple , $ requeue ) ; $ outputFrame -> frameChannelId = $ this -> channel -> getId ( ) ; $ this -> channel -> getConnection ( ) -> command ( $ outputFrame ) ; }
Not Acknowledge the message .
56,276
public function reject ( $ requeue = true ) { $ this -> checkChannel ( ) ; $ outputFrame = BasicRejectFrame :: create ( $ this -> tag , $ requeue ) ; $ outputFrame -> frameChannelId = $ this -> channel -> getId ( ) ; if ( null !== $ requeue ) { $ outputFrame -> requeue = $ requeue ; } $ this -> channel -> getConnection...
Reject the message and requeue it .
56,277
public function convertExceptionToHtml ( $ exception ) { $ flat = $ this -> getFlattenedException ( $ exception ) ; $ handler = new SymfonyExceptionHandler ( ) ; return $ this -> decorate ( $ handler -> getContent ( $ flat ) , $ handler -> getStylesheet ( $ flat ) , $ flat ) ; }
Create a html for the given exception .
56,278
private function decorate ( $ content , $ css , $ exception ) { $ content = $ this -> removeTitle ( $ content ) ; return $ this -> view -> make ( 'sneaker::email.body' , compact ( 'content' , 'css' , 'exception' ) ) -> render ( ) ; }
Get the html response content .
56,279
private function removeTitle ( $ content ) { $ titles = [ 'Whoops, looks like something went wrong.' , 'Sorry, the page you are looking for could not be found.' , ] ; foreach ( $ titles as $ title ) { $ content = str_replace ( "<h1>{$title}</h1>" , '' , $ content ) ; } return $ content ; }
Removes title from content as it is same for all exceptions and has no real value .
56,280
public function captureException ( Exception $ exception , $ sneaking = false ) { try { if ( $ this -> isSilent ( ) ) { return ; } if ( $ this -> isExceptionFromBot ( ) ) { return ; } if ( $ this -> shouldCapture ( $ exception ) ) { $ this -> capture ( $ exception ) ; } } catch ( Exception $ e ) { $ this -> logger -> e...
Checks an exception which should be tracked and captures it if applicable .
56,281
private function capture ( $ exception ) { $ recipients = $ this -> config -> get ( 'sneaker.to' ) ; $ subject = $ this -> handler -> convertExceptionToString ( $ exception ) ; $ body = $ this -> handler -> convertExceptionToHtml ( $ exception ) ; $ this -> mailer -> to ( $ recipients ) -> send ( new ExceptionMailer ( ...
Capture an exception .
56,282
private function shouldCapture ( Exception $ exception ) { $ capture = $ this -> config -> get ( 'sneaker.capture' ) ; if ( ! is_array ( $ capture ) ) { return false ; } if ( in_array ( '*' , $ capture ) ) { return true ; } foreach ( $ capture as $ type ) { if ( $ exception instanceof $ type ) { return true ; } } retur...
Determine if the exception is in the capture list .
56,283
private function isExceptionFromBot ( ) { $ ignored_bots = $ this -> config -> get ( 'sneaker.ignored_bots' ) ; $ agent = array_key_exists ( 'HTTP_USER_AGENT' , $ _SERVER ) ? strtolower ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) : null ; if ( is_null ( $ agent ) ) { return false ; } foreach ( $ ignored_bots as $ bot ) { if ( ...
Determine if the exception is from the bot .
56,284
public function claim ( $ name ) { return isset ( $ this -> data [ $ name ] ) ? $ this -> data [ $ name ] : null ; }
Returns a field from the parsed JWT data .
56,285
public function validateAccessToken ( $ accessToken ) { $ keys = $ this -> getJwtVerificationKeys ( ) ; $ tokenClaims = ( array ) JWT :: decode ( $ accessToken , $ keys , [ 'RS256' ] ) ; if ( $ this -> getClientId ( ) != $ tokenClaims [ 'aud' ] && $ this -> getClientId ( ) != $ tokenClaims [ 'appid' ] ) { throw new \ R...
Validate the access token you received in your application .
56,286
public function getJwtVerificationKeys ( ) { $ factory = $ this -> getRequestFactory ( ) ; $ request = $ factory -> getRequestWithOptions ( 'get' , 'https://login.windows.net/common/discovery/keys' , [ ] ) ; $ response = $ this -> getParsedResponse ( $ request ) ; $ keys = [ ] ; foreach ( $ response [ 'keys' ] as $ i =...
Get JWT verification keys from Azure Active Directory .
56,287
public function getTenantDetails ( $ tenant ) { $ factory = $ this -> getRequestFactory ( ) ; $ request = $ factory -> getRequestWithOptions ( 'get' , 'https://login.windows.net/' . $ tenant . '/.well-known/openid-configuration' , [ ] ) ; $ response = $ this -> getParsedResponse ( $ request ) ; return $ response ; }
Get the specified tenant s details .
56,288
public function copyTo ( Select $ query ) { $ query -> fields = $ this -> fields ; $ query -> distinct = $ this -> distinct ; $ query -> orders = $ this -> orders ; $ query -> groups = $ this -> groups ; $ query -> joins = $ this -> joins ; $ query -> groupResults = $ this -> groupResults ; $ query -> forwardKey = $ th...
Copy current queries select attributes to the given one
56,289
public function fields ( $ fields ) { $ this -> fields = array ( ) ; if ( is_string ( $ fields ) ) { $ fields = $ this -> stringArgumentToArray ( $ fields ) ; } elseif ( is_object ( $ fields ) ) { return $ this -> addField ( $ fields ) ; } if ( empty ( $ fields ) || $ fields === array ( '*' ) || $ fields === array ( ''...
Set the selected fields fields
56,290
public function addFieldCount ( $ field , $ alias = null ) { $ this -> addField ( new Func ( 'count' , $ field ) , $ alias ) ; return $ this ; }
Shortcut to add a count function
56,291
public function addFieldMax ( $ field , $ alias = null ) { $ this -> addField ( new Func ( 'max' , $ field ) , $ alias ) ; return $ this ; }
Shortcut to add a max function
56,292
public function addFieldMin ( $ field , $ alias = null ) { $ this -> addField ( new Func ( 'min' , $ field ) , $ alias ) ; return $ this ; }
Shortcut to add a min function
56,293
public function addFieldSum ( $ field , $ alias = null ) { $ this -> addField ( new Func ( 'sum' , $ field ) , $ alias ) ; return $ this ; }
Shortcut to add a sum function
56,294
public function addFieldAvg ( $ field , $ alias = null ) { $ this -> addField ( new Func ( 'avg' , $ field ) , $ alias ) ; return $ this ; }
Shortcut to add a avg function
56,295
public function addFieldRound ( $ field , $ decimals = 0 , $ alias = null ) { $ this -> addField ( new Func ( 'round' , $ field , new Expression ( ( int ) $ decimals ) ) , $ alias ) ; return $ this ; }
Shortcut to add a price function
56,296
public function orderBy ( $ columns , $ direction = 'asc' ) { if ( is_string ( $ columns ) ) { $ columns = $ this -> stringArgumentToArray ( $ columns ) ; } elseif ( $ columns instanceof Expression ) { $ this -> orders [ ] = array ( $ columns , $ direction ) ; return $ this ; } foreach ( $ columns as $ key => $ column ...
Add an order by statement to the current query
56,297
public function groupBy ( $ groupKeys ) { if ( is_string ( $ groupKeys ) ) { $ groupKeys = $ this -> stringArgumentToArray ( $ groupKeys ) ; } foreach ( $ groupKeys as $ groupKey ) { $ this -> groups [ ] = $ groupKey ; } return $ this ; }
Add a group by statement to the current query
56,298
public function join ( $ table , $ localKey , $ operator = null , $ referenceKey = null , $ type = 'left' ) { if ( ! in_array ( $ type , array ( 'inner' , 'left' , 'right' , 'outer' ) ) ) { throw new Exception ( 'Invalid join type "' . $ type . '" given. Available type: inner, left, right, outer' ) ; } if ( is_object (...
Add a join statement to the current query
56,299
public function leftJoin ( $ table , $ localKey , $ operator = null , $ referenceKey = null ) { return $ this -> join ( $ table , $ localKey , $ operator , $ referenceKey , 'left' ) ; }
Left join same as join with special type