[rt-devel] lib/RT/Ticket.pm introspection callback for Kanban 4.2.12 rt-extension-kanban
Joachim Schiele
js at lastlog.de
Wed Mar 2 07:52:34 EST 2016
hey,
jbrandt recommended to 'override' Ticket.pm to get to the data which we
require for the RESTful Kanban-view. that is:
Ticket.pm:
- sub Create { ... }
- sub _Set { ... }
- sub MergeInto { ... }
so we can either override Ticket.pm as a whole or only have the 3 prior
mentioned functions in our version of Ticket.pm'. this is a nice HACK
but won't work well with different versions.
i propose this:
for 4.2.12+ and 4.4.x we have added a simple callback, like this:
================= current way ================
sub Create {
my $self = shift;
my %args = (
id => undef,
... many more values ...
_RecordTransaction => 1,
DryRun => 0,
@_
);
system("redis-cli", "PUBLISH", "rt-ticket-activity", $self->Id);
================= /current way ================
but instead we should have done this:
================= proposed way ================
# this is the Ticket.pm from rt-4.2.12 with the 'generalized'
# callback interface
# pseudo-code
sub RT_WebSocket_Callback {
# with no implementation
}
sub Create {
my $self = shift;
my %args = (
id => undef,
... many more values ...
_RecordTransaction => 1,
DryRun => 0,
@_
);
RT_WebSocket_Callback( with a array of IDs )
================================================
# this is the Ticket.pm from rt-extension-kanban
sub RT_WebSocket_Callback {
foreach supplied ID
system("redis-cli", "PUBLISH", "rt-ticket-activity", $foo->Id);
}
note: once alco could use Mojo::Redis2 with the sync interface but not
the CPAN Redis as this can't reconnect on redis restarts/crashes and
thus will make RT fail and forces RT to be restarted. this is why we
decided to use the ugly system(...) call for the moment. we are using
Mojo::Redis2 with the async interface in the rt4-websocket mojolicious
server though.
================= /proposed way ================
our motivation for this change is that we have a callback interface to
the Ticket.pm code paths we are interested in, while not forcing any
plugin specific code into RT. if the rt-extension-kanban + rt4-websocket
is used with different versions of Ticket.pm it would unify the API
required to be implemented.
note:
we are planning to release the Kanban view / mojolicious RT::WebSocket
server + rt-extension-kanban this week.
@RT-team
please let us know what you think about this proposal.
regards,
paul & joachim
More information about the rt-devel
mailing list