idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
41,300 | public function moveMember ( $ member ) { $ deferred = new Deferred ( ) ; if ( $ this -> getChannelType ( ) != self :: TYPE_VOICE ) { $ deferred -> reject ( new \ Exception ( 'You cannot move a member in a text channel.' ) ) ; return $ deferred -> promise ( ) ; } if ( $ member instanceof Member ) { $ member = $ member ... | Moves a member to another voice channel . |
41,301 | public function createInvite ( $ max_age = 3600 , $ max_uses = 0 , $ temporary = false , $ xkcd = false ) { $ deferred = new Deferred ( ) ; $ this -> http -> post ( $ this -> replaceWithVariables ( 'channels/:id/invites' ) , [ 'validate' => null , 'max_age' => $ max_age , 'max_uses' => $ max_uses , 'temporary' => $ tem... | Creates an invite for the channel . |
41,302 | public function deleteMessages ( $ messages ) { $ deferred = new Deferred ( ) ; if ( ! is_array ( $ messages ) && ! ( $ messages instanceof Traversable ) ) { $ deferred -> reject ( new \ Exception ( '$messages must be an array or implement Traversable.' ) ) ; return $ deferred -> promise ( ) ; } $ count = count ( $ mes... | Bulk deletes an array of messages . |
41,303 | public function getMessageHistory ( array $ options ) { $ deferred = new Deferred ( ) ; $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefaults ( [ 'limit' => 100 , 'cache' => true ] ) ; $ resolver -> setDefined ( [ 'before' , 'after' , 'around' ] ) ; $ resolver -> setAllowedTypes ( 'before' , [ Message :: cla... | Fetches message history . |
41,304 | public function pinMessage ( Message $ message ) { $ deferred = new Deferred ( ) ; if ( $ message -> pinned ) { return \ React \ Promise \ reject ( new \ Exception ( 'This message is already pinned.' ) ) ; } if ( $ message -> channel_id != $ this -> id ) { return \ React \ Promise \ reject ( new \ Exception ( 'You cann... | Adds a message to the channels pinboard . |
41,305 | public function unpinMessage ( Message $ message ) { $ deferred = new Deferred ( ) ; if ( ! $ message -> pinned ) { return \ React \ Promise \ reject ( new \ Exception ( 'This message is not pinned.' ) ) ; } if ( $ message -> channel_id != $ this -> id ) { return \ React \ Promise \ reject ( new \ Exception ( 'You cann... | Removes a message from the channels pinboard . |
41,306 | public function getPinnedMessages ( ) { $ deferred = new Deferred ( ) ; $ this -> http -> get ( $ this -> replaceWithVariables ( 'channels/:id/pins' ) ) -> then ( function ( $ response ) use ( $ deferred ) { $ messages = new Collection ( ) ; foreach ( $ response as $ message ) { $ message = $ this -> factory -> create ... | Returns the channels pinned messages . |
41,307 | public function getInvites ( ) { $ deferred = new Deferred ( ) ; $ this -> http -> get ( $ this -> replaceWithVariables ( 'channels/:id/invites' ) ) -> then ( function ( $ response ) use ( $ deferred ) { $ invites = new Collection ( ) ; foreach ( $ response as $ invite ) { $ invite = $ this -> factory -> create ( Invit... | Returns the channels invites . |
41,308 | public function setPermissionOverwritesAttribute ( $ overwrites ) { $ this -> attributes [ 'permission_overwrites' ] = $ overwrites ; if ( ! is_null ( $ overwrites ) ) { foreach ( $ overwrites as $ overwrite ) { $ overwrite = ( array ) $ overwrite ; $ overwrite [ 'channel_id' ] = $ this -> id ; $ this -> overwrites -> ... | Sets the permission overwrites attribute . |
41,309 | public function sendMessage ( $ text , $ tts = false , $ embed = null ) { $ deferred = new Deferred ( ) ; if ( $ this -> getChannelType ( ) != self :: TYPE_TEXT ) { $ deferred -> reject ( new \ Exception ( 'You cannot send a message to a voice channel.' ) ) ; return $ deferred -> promise ( ) ; } $ this -> http -> post ... | Sends a message to the channel if it is a text channel . |
41,310 | public function sendFile ( $ filepath , $ filename = null , $ content = null , $ tts = false ) { $ deferred = new Deferred ( ) ; if ( $ this -> getChannelType ( ) != self :: TYPE_TEXT ) { $ deferred -> reject ( new \ Exception ( 'You cannot send a file to a voice channel.' ) ) ; return $ deferred -> promise ( ) ; } if ... | Sends a file to the channel if it is a text channel . |
41,311 | public function getChannelType ( ) { switch ( $ this -> type ) { case self :: TYPE_TEXT : case self :: TYPE_VOICE : return $ this -> type ; break ; default : return self :: TYPE_TEXT ; break ; } } | Returns the channel type . |
41,312 | public function unregisterSubCommand ( $ command ) { if ( ! array_key_exists ( $ command , $ this -> subCommands ) ) { throw new \ Exception ( "A sub-command with the name {$command} does not exist." ) ; } unset ( $ this -> subCommands [ $ command ] ) ; } | Unregisters a sub - command . |
41,313 | public function unregisterSubCommandAlias ( $ alias ) { if ( ! array_key_exists ( $ alias , $ this -> subCommandAliases ) ) { throw new \ Exception ( "A sub-command alias with the name {$alias} does not exist." ) ; } unset ( $ this -> subCommandAliases [ $ alias ] ) ; } | Unregisters a sub - command alias . |
41,314 | public function getHelp ( $ prefix ) { $ helpString = "{$prefix}{$this->command} {$this->usage}- {$this->description}\r\n" ; foreach ( $ this -> subCommands as $ command ) { $ help = $ command -> getHelp ( $ prefix . $ this -> command . ' ' ) ; $ helpString .= " {$help['text']}\r\n" ; } return [ 'text' => $ helpStri... | Gets help for the command . |
41,315 | public function unregisterCommand ( $ command ) { if ( ! array_key_exists ( $ command , $ this -> commands ) ) { throw new \ Exception ( "A command with the name {$command} does not exist." ) ; } unset ( $ this -> commands [ $ command ] ) ; } | Unregisters a command . |
41,316 | public function unregisterCommandAlias ( $ alias ) { if ( ! array_key_exists ( $ alias , $ this -> aliases ) ) { throw new \ Exception ( "A command alias with the name {$alias} does not exist." ) ; } unset ( $ this -> aliases [ $ alias ] ) ; } | Unregisters a command alias . |
41,317 | public function getCommand ( $ command , $ aliases = true ) { if ( array_key_exists ( $ command , $ this -> commands ) ) { return $ this -> commands [ $ command ] ; } if ( array_key_exists ( $ command , $ this -> aliases ) && $ aliases ) { return $ this -> commands [ $ this -> aliases [ $ command ] ] ; } } | Attempts to get a command . |
41,318 | public function buildCommand ( $ command , $ callable , array $ options = [ ] ) { if ( is_string ( $ callable ) ) { $ callable = function ( $ message ) use ( $ callable ) { return $ callable ; } ; } elseif ( is_array ( $ callable ) && ! is_callable ( $ callable ) ) { $ callable = function ( $ message ) use ( $ callable... | Builds a command and returns it . |
41,319 | protected function resolveCommandOptions ( array $ options ) { $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefined ( [ 'description' , 'usage' , 'aliases' , ] ) -> setDefaults ( [ 'description' => 'No description provided.' , 'usage' => '' , 'aliases' => [ ] , ] ) ; $ options = $ resolver -> resolve ( $ opt... | Resolves command options . |
41,320 | public function writeChar ( $ value , $ offset ) { $ this -> insert ( 'c' , $ value , $ offset , $ this -> lengthMap -> getLengthFor ( 'c' ) ) ; } | Writes a char . |
41,321 | public function writeRawString ( $ value , $ offset ) { for ( $ i = 0 ; $ i < strlen ( $ value ) ; ++ $ i ) { $ this -> buffer [ $ offset ++ ] = $ value [ $ i ] ; } } | Writes a binary string to the buffer . |
41,322 | public function getUserAttribute ( ) { if ( $ this -> discord -> users -> has ( $ this -> attributes [ 'user' ] -> id ) ) { return $ this -> discord -> users -> get ( $ this -> attributes [ 'user' ] -> id ) ; } return $ this -> factory -> create ( User :: class , ( array ) $ this -> attributes [ 'user' ] , true ) ; } | Gets the user attribute . |
41,323 | public function getPrivateChannel ( ) { $ deferred = new Deferred ( ) ; if ( $ this -> cache -> has ( "pm_channel.{$this->id}" ) ) { $ deferred -> resolve ( $ this -> cache -> get ( "pm_channel.{$this->id}" ) ) ; } else { $ this -> http -> post ( 'users/@me/channels' , [ 'recipient_id' => $ this -> id ] ) -> then ( fun... | Gets the private channel for the user . |
41,324 | public function sendMessage ( $ message , $ tts = false ) { $ deferred = new Deferred ( ) ; $ this -> getPrivateChannel ( ) -> then ( function ( $ channel ) use ( $ message , $ tts , $ deferred ) { $ channel -> sendMessage ( $ message , $ tts ) -> then ( function ( $ response ) use ( $ deferred ) { $ message = $ this -... | Sends a message to the user . |
41,325 | public function ban ( $ daysToDeleteMessasges = null ) { $ deferred = new Deferred ( ) ; $ content = [ ] ; $ url = $ this -> replaceWithVariables ( 'guilds/:guild_id/bans/:id' ) ; if ( ! is_null ( $ daysToDeleteMessasges ) ) { $ content [ 'delete-message-days' ] = $ daysToDeleteMessasges ; } $ this -> http -> put ( $ u... | Bans the member . |
41,326 | public function setNickname ( $ nick = null ) { $ deferred = new Deferred ( ) ; $ nick = $ nick ? : '' ; $ payload = [ 'nick' => $ nick , ] ; if ( $ this -> discord -> id == $ this -> user -> id ) { $ promise = $ this -> http -> patch ( "guilds/{$this->guild_id}/members/@me/nick" , $ payload ) ; } else { $ promise = $ ... | Sets the nickname of the member . |
41,327 | public function moveMember ( $ channel ) { $ deferred = new Deferred ( ) ; if ( $ channel instanceof Channel ) { $ channel = $ channel -> id ; } $ this -> http -> patch ( "guilds/{$this->guild_id}/members/{$this->id}" , [ 'channel_id' => $ channel , ] ) -> then ( function ( ) use ( $ deferred ) { $ deferred -> resolve ... | Moves the member to another voice channel . |
41,328 | public function addRole ( $ role ) { if ( $ role instanceof Role ) { $ role = $ role -> id ; } if ( false !== array_search ( $ role , ( array ) $ this -> attributes [ 'roles' ] ) ) { return false ; } $ this -> attributes [ 'roles' ] [ ] = $ role ; return true ; } | Adds a role to the member . |
41,329 | public function removeRole ( $ role ) { if ( $ role instanceof Role ) { $ role = $ role -> id ; } if ( false !== ( $ index = array_search ( $ role , $ this -> attributes [ 'roles' ] ) ) ) { unset ( $ this -> attributes [ 'roles' ] [ $ index ] ) ; } return true ; } | Removes a role from the user . |
41,330 | public function getGameAttribute ( ) { if ( ! array_key_exists ( 'game' , $ this -> attributes ) ) { $ this -> attributes [ 'game' ] = [ ] ; } return $ this -> factory -> create ( Game :: class , ( array ) $ this -> attributes [ 'game' ] , true ) ; } | Gets the game attribute . |
41,331 | protected function event ( $ queue , $ event ) { if ( $ this -> container && $ this -> container -> bound ( Dispatcher :: class ) ) { $ queue = Str :: replaceFirst ( 'queues:' , '' , $ queue ) ; $ this -> container -> make ( Dispatcher :: class ) -> dispatch ( $ event -> connection ( $ this -> getConnectionName ( ) ) -... | Fire the given event if a dispatcher is bound . |
41,332 | protected function start ( $ supervisor ) { if ( $ supervisor -> options -> nice ) { proc_nice ( $ supervisor -> options -> nice ) ; } $ supervisor -> handleOutputUsing ( function ( $ type , $ line ) { $ this -> output -> write ( $ line ) ; } ) ; $ supervisor -> working = ! $ this -> option ( 'paused' ) ; $ supervisor ... | Start the given supervisor . |
41,333 | protected function supervisorOptions ( ) { return new SupervisorOptions ( $ this -> argument ( 'name' ) , $ this -> argument ( 'connection' ) , $ this -> getQueue ( $ this -> argument ( 'connection' ) ) , $ this -> option ( 'balance' ) , $ this -> option ( 'delay' ) , $ this -> option ( 'max-processes' ) , $ this -> op... | Get the supervisor options . |
41,334 | protected function registerEvents ( ) { $ events = $ this -> app -> make ( Dispatcher :: class ) ; foreach ( $ this -> events as $ event => $ listeners ) { foreach ( $ listeners as $ listener ) { $ events -> listen ( $ event , $ listener ) ; } } } | Register the Horizon job events . |
41,335 | protected function registerRoutes ( ) { Route :: group ( [ 'domain' => config ( 'horizon.domain' , null ) , 'prefix' => config ( 'horizon.path' ) , 'namespace' => 'Laravel\Horizon\Http\Controllers' , 'middleware' => config ( 'horizon.middleware' , 'web' ) , ] , function ( ) { $ this -> loadRoutesFrom ( __DIR__ . '/../r... | Register the Horizon routes . |
41,336 | protected function registerQueueConnectors ( ) { $ this -> app -> resolving ( QueueManager :: class , function ( $ manager ) { $ manager -> addConnector ( 'redis' , function ( ) { return new RedisConnector ( $ this -> app [ 'redis' ] ) ; } ) ; } ) ; } | Register the custom queue connectors for Horizon . |
41,337 | protected function offerPublishing ( ) { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ __DIR__ . '/../stubs/HorizonServiceProvider.stub' => app_path ( 'Providers/HorizonServiceProvider.php' ) , ] , 'horizon-provider' ) ; $ this -> publishes ( [ __DIR__ . '/../config/horizon.php' => config_path ... | Setup the resource publishing groups for Horizon . |
41,338 | protected function registerServices ( ) { foreach ( $ this -> serviceBindings as $ key => $ value ) { is_numeric ( $ key ) ? $ this -> app -> singleton ( $ value ) : $ this -> app -> singleton ( $ key , $ value ) ; } } | Register Horizon s services in the container . |
41,339 | protected function registerCommands ( ) { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> commands ( [ Console \ InstallCommand :: class , Console \ AssetsCommand :: class , Console \ HorizonCommand :: class , Console \ ListCommand :: class , Console \ PurgeCommand :: class , Console \ PauseCommand :: class , ... | Register the Horizon Artisan commands . |
41,340 | public static function use ( $ connection ) { if ( ! is_null ( $ config = config ( "database.redis.clusters.{$connection}.0" ) ) ) { config ( [ "database.redis.{$connection}" => $ config ] ) ; } elseif ( is_null ( $ config ) && is_null ( $ config = config ( "database.redis.{$connection}" ) ) ) { throw new Exception ( "... | Configure the Redis databases that will store Horizon data . |
41,341 | public function get ( ) { $ processes = $ this -> processes ( ) ; return collect ( $ this -> waitTime -> calculate ( ) ) -> map ( function ( $ waitTime , $ queue ) use ( $ processes ) { [ $ connection , $ queueName ] = explode ( ':' , $ queue , 2 ) ; $ length = ! Str :: contains ( $ queue , ',' ) ? $ this -> queue -> c... | Get the current workload of each queue . |
41,342 | private function processes ( ) { return collect ( $ this -> supervisors -> all ( ) ) -> pluck ( 'processes' ) -> reduce ( function ( $ final , $ queues ) { foreach ( $ queues as $ queue => $ processes ) { $ final [ $ queue ] = isset ( $ final [ $ queue ] ) ? $ final [ $ queue ] + $ processes : $ processes ; } return $ ... | Get the number of processes of each queue . |
41,343 | public function get ( array $ names ) { $ records = $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ names ) { foreach ( $ names as $ name ) { $ pipe -> hmget ( 'supervisor:' . $ name , [ 'name' , 'master' , 'pid' , 'status' , 'processes' , 'options' ] ) ; } } ) ; return collect ( $ records ) -> filte... | Get information on the given supervisors . |
41,344 | public function update ( Supervisor $ supervisor ) { $ processes = $ supervisor -> processPools -> mapWithKeys ( function ( $ pool ) use ( $ supervisor ) { return [ $ supervisor -> options -> connection . ':' . $ pool -> queue ( ) => count ( $ pool -> processes ( ) ) ] ; } ) -> toJson ( ) ; $ this -> connection ( ) -> ... | Update the information about the given supervisor process . |
41,345 | public function forget ( $ names ) { $ names = ( array ) $ names ; if ( empty ( $ names ) ) { return ; } $ this -> connection ( ) -> del ( ... collect ( $ names ) -> map ( function ( $ name ) { return 'supervisor:' . $ name ; } ) -> all ( ) ) ; $ this -> connection ( ) -> zrem ( 'supervisors' , ... $ names ) ; } | Remove the supervisor information from storage . |
41,346 | public function measuredJobs ( ) { $ classes = ( array ) $ this -> connection ( ) -> smembers ( 'measured_jobs' ) ; return collect ( $ classes ) -> map ( function ( $ class ) { return preg_match ( '/job:(.*)$/' , $ class , $ matches ) ? $ matches [ 1 ] : $ class ; } ) -> all ( ) ; } | Get all of the class names that have metrics measurements . |
41,347 | public function measuredQueues ( ) { $ queues = ( array ) $ this -> connection ( ) -> smembers ( 'measured_queues' ) ; return collect ( $ queues ) -> map ( function ( $ class ) { return preg_match ( '/queue:(.*)$/' , $ class , $ matches ) ? $ matches [ 1 ] : $ class ; } ) -> all ( ) ; } | Get all of the queues that have metrics measurements . |
41,348 | public function throughput ( ) { return collect ( $ this -> measuredQueues ( ) ) -> reduce ( function ( $ carry , $ queue ) { return $ carry + $ this -> connection ( ) -> hget ( 'queue:' . $ queue , 'throughput' ) ; } , 0 ) ; } | Get the application s total throughput since the last snapshot . |
41,349 | public function queueWithMaximumRuntime ( ) { return collect ( $ this -> measuredQueues ( ) ) -> sortBy ( function ( $ queue ) { if ( $ snapshots = $ this -> connection ( ) -> zrange ( 'snapshot:queue:' . $ queue , - 1 , 1 ) ) { return json_decode ( $ snapshots [ 0 ] ) -> runtime ; } } ) -> last ( ) ; } | Get the queue that has the longest runtime . |
41,350 | public function queueWithMaximumThroughput ( ) { return collect ( $ this -> measuredQueues ( ) ) -> sortBy ( function ( $ queue ) { if ( $ snapshots = $ this -> connection ( ) -> zrange ( 'snapshot:queue:' . $ queue , - 1 , 1 ) ) { return json_decode ( $ snapshots [ 0 ] ) -> throughput ; } } ) -> last ( ) ; } | Get the queue that has the most throughput . |
41,351 | public function incrementJob ( $ job , $ runtime ) { $ this -> connection ( ) -> eval ( LuaScripts :: updateMetrics ( ) , 2 , 'job:' . $ job , 'measured_jobs' , str_replace ( ',' , '.' , $ runtime ) ) ; } | Increment the metrics information for a job . |
41,352 | public function incrementQueue ( $ queue , $ runtime ) { $ this -> connection ( ) -> eval ( LuaScripts :: updateMetrics ( ) , 2 , 'queue:' . $ queue , 'measured_queues' , str_replace ( ',' , '.' , $ runtime ) ) ; } | Increment the metrics information for a queue . |
41,353 | protected function snapshotsFor ( $ key ) { return collect ( $ this -> connection ( ) -> zrange ( 'snapshot:' . $ key , 0 , - 1 ) ) -> map ( function ( $ snapshot ) { return ( object ) json_decode ( $ snapshot , true ) ; } ) -> values ( ) -> all ( ) ; } | Get all of the snapshots for the given key . |
41,354 | public function snapshot ( ) { collect ( $ this -> measuredJobs ( ) ) -> each ( function ( $ job ) { $ this -> storeSnapshotForJob ( $ job ) ; } ) ; collect ( $ this -> measuredQueues ( ) ) -> each ( function ( $ queue ) { $ this -> storeSnapshotForQueue ( $ queue ) ; } ) ; $ this -> storeSnapshotTimestamp ( ) ; } | Store a snapshot of the metrics information . |
41,355 | protected function storeSnapshotForJob ( $ job ) { $ data = $ this -> baseSnapshotData ( $ key = 'job:' . $ job ) ; $ this -> connection ( ) -> zadd ( 'snapshot:' . $ key , $ time = Chronos :: now ( ) -> getTimestamp ( ) , json_encode ( [ 'throughput' => $ data [ 'throughput' ] , 'runtime' => $ data [ 'runtime' ] , 'ti... | Store a snapshot for the given job . |
41,356 | protected function storeSnapshotForQueue ( $ queue ) { $ data = $ this -> baseSnapshotData ( $ key = 'queue:' . $ queue ) ; $ this -> connection ( ) -> zadd ( 'snapshot:' . $ key , $ time = Chronos :: now ( ) -> getTimestamp ( ) , json_encode ( [ 'throughput' => $ data [ 'throughput' ] , 'runtime' => $ data [ 'runtime'... | Store a snapshot for the given queue . |
41,357 | protected function baseSnapshotData ( $ key ) { $ responses = $ this -> connection ( ) -> transaction ( function ( $ trans ) use ( $ key ) { $ trans -> hmget ( $ key , [ 'throughput' , 'runtime' ] ) ; $ trans -> del ( $ key ) ; } ) ; $ snapshot = array_values ( $ responses [ 0 ] ) ; return [ 'throughput' => $ snapshot ... | Get the base snapshot data for a given key . |
41,358 | protected function minutesSinceLastSnapshot ( ) { $ lastSnapshotAt = $ this -> connection ( ) -> get ( 'last_snapshot_at' ) ? : $ this -> storeSnapshotTimestamp ( ) ; return max ( ( Chronos :: now ( ) -> getTimestamp ( ) - $ lastSnapshotAt ) / 60 , 1 ) ; } | Get the number of minutes passed since the last snapshot . |
41,359 | protected function storeSnapshotTimestamp ( ) { return tap ( Chronos :: now ( ) -> getTimestamp ( ) , function ( $ timestamp ) { $ this -> connection ( ) -> set ( 'last_snapshot_at' , $ timestamp ) ; } ) ; } | Store the current timestamp as the last snapshot timestamp . |
41,360 | public function toArray ( ) { return [ 'balance' => $ this -> balance , 'connection' => $ this -> connection , 'queue' => $ this -> queue , 'delay' => $ this -> delay , 'force' => $ this -> force , 'maxProcesses' => $ this -> maxProcesses , 'minProcesses' => $ this -> minProcesses , 'maxTries' => $ this -> maxTries , '... | Convert the options to a raw array . |
41,361 | public function index ( ) { return [ 'jobsPerMinute' => app ( MetricsRepository :: class ) -> jobsProcessedPerMinute ( ) , 'processes' => $ this -> totalProcessCount ( ) , 'queueWithMaxRuntime' => app ( MetricsRepository :: class ) -> queueWithMaximumRuntime ( ) , 'queueWithMaxThroughput' => app ( MetricsRepository :: ... | Get the key performance stats for the dashboard . |
41,362 | protected function totalProcessCount ( ) { $ supervisors = app ( SupervisorRepository :: class ) -> all ( ) ; return collect ( $ supervisors ) -> reduce ( function ( $ carry , $ supervisor ) { return $ carry + collect ( $ supervisor -> processes ) -> sum ( ) ; } , 0 ) ; } | Get the total process count across all supervisors . |
41,363 | protected function currentStatus ( ) { if ( ! $ masters = app ( MasterSupervisorRepository :: class ) -> all ( ) ) { return 'inactive' ; } return collect ( $ masters ) -> contains ( function ( $ master ) { return $ master -> status === 'paused' ; } ) ? 'paused' : 'running' ; } | Get the current status of Horizon . |
41,364 | protected function getJobsByType ( $ type , $ afterIndex ) { $ afterIndex = $ afterIndex === null ? - 1 : $ afterIndex ; return $ this -> getJobs ( $ this -> connection ( ) -> zrange ( $ type , $ afterIndex + 1 , $ afterIndex + 50 ) , $ afterIndex + 1 ) ; } | Get a chunk of jobs from the given type set . |
41,365 | protected function countJobsByType ( $ type ) { $ minutes = $ type === 'failed_jobs' ? $ this -> failedJobExpires : $ this -> recentJobExpires ; return $ this -> connection ( ) -> zcount ( $ type , '-inf' , Chronos :: now ( ) -> subMinutes ( $ minutes ) -> getTimestamp ( ) * - 1 ) ; } | Get the number of jobs in a given type set . |
41,366 | public function getJobs ( array $ ids , $ indexFrom = 0 ) { $ jobs = $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ ids ) { foreach ( $ ids as $ id ) { $ pipe -> hmget ( $ id , $ this -> keys ) ; } } ) ; return $ this -> indexJobs ( collect ( $ jobs ) -> filter ( function ( $ job ) { $ job = is_arra... | Retrieve the jobs with the given IDs . |
41,367 | protected function indexJobs ( $ jobs , $ indexFrom ) { return $ jobs -> map ( function ( $ job ) use ( & $ indexFrom ) { $ job = ( object ) array_combine ( $ this -> keys , $ job ) ; $ job -> index = $ indexFrom ; $ indexFrom ++ ; return $ job ; } ) ; } | Index the given jobs from the given index . |
41,368 | public function pushed ( $ connection , $ queue , JobPayload $ payload ) { $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ connection , $ queue , $ payload ) { $ this -> storeJobReference ( $ pipe , 'recent_jobs' , $ payload ) ; $ time = str_replace ( ',' , '.' , microtime ( true ) ) ; $ pipe -> hmse... | Insert the job into storage . |
41,369 | public function reserved ( $ connection , $ queue , JobPayload $ payload ) { $ time = str_replace ( ',' , '.' , microtime ( true ) ) ; $ this -> connection ( ) -> hmset ( $ payload -> id ( ) , [ 'status' => 'reserved' , 'payload' => $ payload -> value , 'updated_at' => $ time , 'reserved_at' => $ time , ] ) ; } | Mark the job as reserved . |
41,370 | public function completed ( JobPayload $ payload , $ failed = false ) { if ( $ payload -> isRetry ( ) ) { $ this -> updateRetryInformationOnParent ( $ payload , $ failed ) ; } $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ payload , $ failed ) { $ this -> markJobAsCompleted ( $ pipe , $ payload -> i... | Handle the storage of a completed job . |
41,371 | protected function markJobAsCompleted ( $ pipe , $ id , $ failed ) { $ failed ? $ pipe -> hmset ( $ id , [ 'status' => 'failed' ] ) : $ pipe -> hmset ( $ id , [ 'status' => 'completed' , 'completed_at' => str_replace ( ',' , '.' , microtime ( true ) ) ] ) ; $ pipe -> expireat ( $ id , Chronos :: now ( ) -> addMinutes (... | Mark a given job as completed and set it to expire . |
41,372 | protected function updateRetryInformationOnParent ( JobPayload $ payload , $ failed ) { if ( $ retries = $ this -> connection ( ) -> hget ( $ payload -> retryOf ( ) , 'retried_by' ) ) { $ retries = $ this -> updateRetryStatus ( $ payload , json_decode ( $ retries , true ) , $ failed ) ; $ this -> connection ( ) -> hset... | Update the retry status of a job s parent . |
41,373 | protected function updateRetryStatus ( JobPayload $ payload , $ retries , $ failed ) { return collect ( $ retries ) -> map ( function ( $ retry ) use ( $ payload , $ failed ) { return $ retry [ 'id' ] === $ payload -> id ( ) ? Arr :: set ( $ retry , 'status' , $ failed ? 'failed' : 'completed' ) : $ retry ; } ) -> all ... | Update the retry status of a job in a retry array . |
41,374 | public function deleteMonitored ( array $ ids ) { $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ ids ) { foreach ( $ ids as $ id ) { $ pipe -> expireat ( $ id , Chronos :: now ( ) -> addDays ( 7 ) -> getTimestamp ( ) ) ; } } ) ; } | Delete the given monitored jobs by IDs . |
41,375 | public function trimRecentJobs ( ) { $ this -> connection ( ) -> pipeline ( function ( $ pipe ) { $ score = Chronos :: now ( ) -> subMinutes ( $ this -> recentJobExpires ) -> getTimestamp ( ) * - 1 ; $ pipe -> zremrangebyscore ( 'recent_jobs' , $ score , '+inf' ) ; $ pipe -> zremrangebyscore ( 'recent_failed_jobs' , $ ... | Trim the recent job list . |
41,376 | public function trimFailedJobs ( ) { $ this -> connection ( ) -> zremrangebyscore ( 'failed_jobs' , Chronos :: now ( ) -> subMinutes ( $ this -> failedJobExpires ) -> getTimestamp ( ) * - 1 , '+inf' ) ; } | Trim the failed job list . |
41,377 | public function trimMonitoredJobs ( ) { $ this -> connection ( ) -> zremrangebyscore ( 'monitored_jobs' , Chronos :: now ( ) -> subMinutes ( $ this -> monitoredJobExpires ) -> getTimestamp ( ) * - 1 , '+inf' ) ; } | Trim the monitored job list . |
41,378 | public function findFailed ( $ id ) { $ attributes = $ this -> connection ( ) -> hmget ( $ id , $ this -> keys ) ; $ job = is_array ( $ attributes ) && $ attributes [ 0 ] !== null ? ( object ) array_combine ( $ this -> keys , $ attributes ) : null ; if ( $ job && $ job -> status !== 'failed' ) { return ; } return $ job... | Find a failed job by ID . |
41,379 | public function failed ( $ exception , $ connection , $ queue , JobPayload $ payload ) { $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ exception , $ connection , $ queue , $ payload ) { $ this -> storeJobReference ( $ pipe , 'failed_jobs' , $ payload ) ; $ this -> storeJobReference ( $ pipe , 'rece... | Mark the job as failed . |
41,380 | protected function storeJobReference ( $ pipe , $ key , JobPayload $ payload ) { $ pipe -> zadd ( $ key , str_replace ( ',' , '.' , microtime ( true ) * - 1 ) , $ payload -> id ( ) ) ; } | Store the look - up references for a job . |
41,381 | public function storeRetryReference ( $ id , $ retryId ) { $ retries = json_decode ( $ this -> connection ( ) -> hget ( $ id , 'retried_by' ) ? : '[]' ) ; $ retries [ ] = [ 'id' => $ retryId , 'status' => 'pending' , 'retried_at' => Chronos :: now ( ) -> getTimestamp ( ) , ] ; $ this -> connection ( ) -> hmset ( $ id ,... | Store the retry job ID on the original job record . |
41,382 | public function deleteFailed ( $ id ) { $ this -> connection ( ) -> zrem ( 'failed_jobs' , $ id ) ; $ this -> connection ( ) -> del ( $ id ) ; } | Delete a failed job by ID . |
41,383 | public function update ( MasterSupervisor $ master ) { $ supervisors = $ master -> supervisors -> map -> name -> all ( ) ; $ this -> connection ( ) -> pipeline ( function ( $ pipe ) use ( $ master , $ supervisors ) { $ pipe -> hmset ( 'master:' . $ master -> name , [ 'name' => $ master -> name , 'pid' => $ master -> pi... | Update the information about the given master supervisor . |
41,384 | public function forget ( $ name ) { if ( ! $ master = $ this -> find ( $ name ) ) { return ; } app ( SupervisorRepository :: class ) -> forget ( $ master -> supervisors ) ; $ this -> connection ( ) -> del ( 'master:' . $ name ) ; $ this -> connection ( ) -> zrem ( 'masters' , $ name ) ; } | Remove the master supervisor information from storage . |
41,385 | public function terminate ( $ status = 0 ) { $ this -> working = false ; $ longest = app ( SupervisorRepository :: class ) -> longestActiveTimeout ( ) ; $ this -> supervisors -> each -> terminate ( ) ; app ( MasterSupervisorRepository :: class ) -> forget ( $ this -> name ) ; $ startedTerminating = Chronos :: now ( ) ;... | Terminate this master supervisor and all of its supervisors . |
41,386 | protected function processPendingCommands ( ) { foreach ( app ( HorizonCommandQueue :: class ) -> pending ( $ this -> commandQueue ( ) ) as $ command ) { app ( $ command -> command ) -> process ( $ this , $ command -> options ) ; } } | Handle any pending commands for the master supervisor . |
41,387 | protected function monitorSupervisors ( ) { $ this -> supervisors -> each -> monitor ( ) ; $ this -> supervisors = $ this -> supervisors -> reject -> dead ; } | Monitor all of the supervisors . |
41,388 | protected function createProcessPoolPerQueue ( ) { return collect ( explode ( ',' , $ this -> options -> queue ) ) -> map ( function ( $ queue ) { return $ this -> createProcessPool ( $ this -> options -> withQueue ( $ queue ) ) ; } ) ; } | Create a process pool for each queue . |
41,389 | protected function createProcessPool ( SupervisorOptions $ options ) { return new ProcessPool ( $ options , function ( $ type , $ line ) { $ this -> output ( $ type , $ line ) ; } ) ; } | Create a new process pool with the given options . |
41,390 | public function balance ( array $ balance ) { foreach ( $ balance as $ queue => $ scale ) { $ this -> processPools -> first ( function ( $ pool ) use ( $ queue ) { return $ pool -> queue ( ) === $ queue ; } , new class { public function __call ( $ method , $ arguments ) { } } ) -> scale ( $ scale ) ; } } | Balance the process pool at the given scales . |
41,391 | public function terminate ( $ status = 0 ) { $ this -> working = false ; app ( SupervisorRepository :: class ) -> forget ( $ this -> name ) ; $ this -> processPools -> each ( function ( $ pool ) { $ pool -> processes ( ) -> each ( function ( $ process ) { $ process -> terminate ( ) ; } ) ; } ) ; if ( $ this -> shouldWa... | Terminate this supervisor process and all of its workers . |
41,392 | protected function autoScale ( ) { $ this -> lastAutoScaled = $ this -> lastAutoScaled ? : Chronos :: now ( ) -> subSeconds ( $ this -> autoScaleCooldown + 1 ) ; if ( Chronos :: now ( ) -> subSeconds ( $ this -> autoScaleCooldown ) -> gte ( $ this -> lastAutoScaled ) ) { $ this -> lastAutoScaled = Chronos :: now ( ) ; ... | Run the auto - scaling routine for the supervisor . |
41,393 | public function prepare ( $ job ) { return $ this -> set ( [ 'type' => $ this -> determineType ( $ job ) , 'tags' => $ this -> determineTags ( $ job ) , 'pushedAt' => str_replace ( ',' , '.' , microtime ( true ) ) , ] ) ; } | Prepare the payload for storage on the queue by adding tags etc . |
41,394 | protected function determineType ( $ job ) { switch ( true ) { case $ job instanceof BroadcastEvent : return 'broadcast' ; case $ job instanceof CallQueuedListener : return 'event' ; case $ job instanceof SendQueuedMailable : return 'mail' ; case $ job instanceof SendQueuedNotifications : return 'notification' ; defaul... | Get the type of job being queued . |
41,395 | protected function determineTags ( $ job ) { switch ( true ) { case is_string ( $ job ) : return [ ] ; case array_key_exists ( 'tags' , $ this -> decoded ) : return $ this -> decoded [ 'tags' ] ; default : return Tags :: for ( $ job ) ; } } | Get the appropriate tags for the job . |
41,396 | public function index ( Request $ request ) { $ jobs = ! $ request -> query ( 'tag' ) ? $ this -> paginate ( $ request ) : $ this -> paginateByTag ( $ request , $ request -> query ( 'tag' ) ) ; $ total = $ request -> query ( 'tag' ) ? $ this -> tags -> count ( 'failed:' . $ request -> query ( 'tag' ) ) : $ this -> jobs... | Get all of the failed jobs . |
41,397 | protected function paginate ( Request $ request ) { return $ this -> jobs -> getFailed ( $ request -> query ( 'starting_at' ) ? : - 1 ) -> map ( function ( $ job ) { return $ this -> decode ( $ job ) ; } ) ; } | Paginate the failed jobs for the request . |
41,398 | protected function paginateByTag ( Request $ request , $ tag ) { $ jobIds = $ this -> tags -> paginate ( 'failed:' . $ tag , $ request -> query ( 'starting_at' , - 1 ) + 1 , 50 ) ; $ startingAt = $ request -> query ( 'starting_at' , 0 ) ; return $ this -> jobs -> getJobs ( $ jobIds , $ startingAt ) -> map ( function ( ... | Paginate the failed jobs for the request and tag . |
41,399 | public function show ( $ id ) { return ( array ) $ this -> jobs -> getJobs ( [ $ id ] ) -> map ( function ( $ job ) { return $ this -> decode ( $ job ) ; } ) -> first ( ) ; } | Get a failed job instance . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.