New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled tasks output to Slack..? #122

Closed
stokic opened this Issue Jun 22, 2016 · 12 comments

Comments

Projects
None yet
7 participants
@stokic

stokic commented Jun 22, 2016

The idea is simple, to send output of the scheduled tasks to specified Slack hook/channel, just like we have it for email.

I've already have the code ready just wanted to check if community would consider this a good idea or something stupid :)

The command would be simple in line with the current emailOutputTo ie something like this:

$schedule->command('inspire')->daily()->sendOutputTo($filePath)->sendOutputToSlack($slackHookURL, $slackChannel);

@adamtester

This comment has been minimized.

Show comment
Hide comment
@adamtester

adamtester Jun 22, 2016

I like the idea, but probably a config file with the slack channels and hook urls and then use
sendOutputTo($provider)
Then you can plug in HipChat or other hooks in.

adamtester commented Jun 22, 2016

I like the idea, but probably a config file with the slack channels and hook urls and then use
sendOutputTo($provider)
Then you can plug in HipChat or other hooks in.

@stokic

This comment has been minimized.

Show comment
Hide comment
@stokic

stokic Jun 22, 2016

That's up for the discussion, it's one of the things I haven't decided on yet and where I would like some feedback from people...

We could make it more general of course if that's what "people" want ;)

stokic commented Jun 22, 2016

That's up for the discussion, it's one of the things I haven't decided on yet and where I would like some feedback from people...

We could make it more general of course if that's what "people" want ;)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 22, 2016

sounds very useful 👍

ghost commented Jun 22, 2016

sounds very useful 👍

@taylorotwell

This comment has been minimized.

Show comment
Hide comment
@taylorotwell

taylorotwell Jun 22, 2016

Member

Do we have an "after" hook which could be used to send notifications to whatever service you want?

Member

taylorotwell commented Jun 22, 2016

Do we have an "after" hook which could be used to send notifications to whatever service you want?

@stokic

This comment has been minimized.

Show comment
Hide comment
@stokic

stokic Jun 22, 2016

There is an "after" hook according to the documentation and of course it could be used but I was thinking of keeping in line with the current email notification implementation.

stokic commented Jun 22, 2016

There is an "after" hook according to the documentation and of course it could be used but I was thinking of keeping in line with the current email notification implementation.

@fitztrev

This comment has been minimized.

Show comment
Hide comment
@fitztrev

fitztrev Jun 23, 2016

I proposed something similar in #7 with ->thenPost($url) so that it could be used for other services as well.

fitztrev commented Jun 23, 2016

I proposed something similar in #7 with ->thenPost($url) so that it could be used for other services as well.

@nticaric

This comment has been minimized.

Show comment
Hide comment
@nticaric

nticaric Jun 23, 2016

@adamtester has a good point and here's a concrete implementation for the sendOutputTo method.
This piece of code would allow us to entirely remove the email related methods and cleanup the code. The provider would take the responsibility of sending the output to email/slack/hipchat which is of course a better separation of concerns and gives us more flexibility like ie. changing the email title.

public function sendOutputTo(SchedulingOutputProvider $provider)
{
    if (is_null($this->output) || $this->output == $this->getDefaultOutput()) {
        throw new LogicException('Must direct output to a file in order to send results to provider.');
    }

    $params = [
        'text'        => file_get_contents($this->output),
        'description' => $this->description
    ]

    return $this->then(function () use ($params) {
        $provider->send($params);
    });
}

The SchedulingOutputProvider interface declaration would only have an send method

nticaric commented Jun 23, 2016

@adamtester has a good point and here's a concrete implementation for the sendOutputTo method.
This piece of code would allow us to entirely remove the email related methods and cleanup the code. The provider would take the responsibility of sending the output to email/slack/hipchat which is of course a better separation of concerns and gives us more flexibility like ie. changing the email title.

public function sendOutputTo(SchedulingOutputProvider $provider)
{
    if (is_null($this->output) || $this->output == $this->getDefaultOutput()) {
        throw new LogicException('Must direct output to a file in order to send results to provider.');
    }

    $params = [
        'text'        => file_get_contents($this->output),
        'description' => $this->description
    ]

    return $this->then(function () use ($params) {
        $provider->send($params);
    });
}

The SchedulingOutputProvider interface declaration would only have an send method

@stokic

This comment has been minimized.

Show comment
Hide comment
@stokic

stokic Jun 24, 2016

I would support this suggestion from @nticaric, I think it's a good idea to have multiple providers available although I only need Slack :P

stokic commented Jun 24, 2016

I would support this suggestion from @nticaric, I think it's a good idea to have multiple providers available although I only need Slack :P

@lucasmichot

This comment has been minimized.

Show comment
Hide comment
@lucasmichot

lucasmichot Jun 24, 2016

@stokic Why don't you just use https://github.com/NotifyMeHQ/laravel inside \Illuminate\Console\Scheduling\Event::then ?

lucasmichot commented Jun 24, 2016

@stokic Why don't you just use https://github.com/NotifyMeHQ/laravel inside \Illuminate\Console\Scheduling\Event::then ?

@stokic

This comment has been minimized.

Show comment
Hide comment
@stokic

stokic Jun 24, 2016

I actually wrote my own Slack notifier (it's really just a couple of lines of code) for my own needs but since I saw that email notification is "baked in" I've suggested to bake in Slack too. But yes of course one could use this package.... :)

stokic commented Jun 24, 2016

I actually wrote my own Slack notifier (it's really just a couple of lines of code) for my own needs but since I saw that email notification is "baked in" I've suggested to bake in Slack too. But yes of course one could use this package.... :)

@jasonmccallister

This comment has been minimized.

Show comment
Hide comment
@jasonmccallister

jasonmccallister Aug 16, 2016

Looks like this is built into Notifications now :)

jasonmccallister commented Aug 16, 2016

Looks like this is built into Notifications now :)

@stokic

This comment has been minimized.

Show comment
Hide comment
@stokic

stokic Aug 16, 2016

Looks like an old developer's rule was in play: if you wait long enough, the problem will go away :D

stokic commented Aug 16, 2016

Looks like an old developer's rule was in play: if you wait long enough, the problem will go away :D

@stokic stokic closed this Aug 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment