Skip to content

Commit

Permalink
log/request_logger_implementation (#95)
Browse files Browse the repository at this point in the history
* dispatch logger context

* change data object

* request logger and dispatch context work

* trigger tests [ci] 2023-10-17 05:43:33

* logger enhancement and growth testing

* trigger tests 2023-10-18 12:56:19

* fix test and log level messaging

* Update lib/Mojo/WebSocketProxy/Dispatcher.pm

logger object

Co-authored-by: Hani Kh <108520819+hani-deriv@users.noreply.github.com>

* request handler added

* trigger tests 2023-10-25 13:08:20

* remove debugging logs

* fix changes for name

* changes file fixed

* update version

* fix pod and critic failing for logger

* v0.15

    -Logger Wrapper added to Proxy for logging context with request

* trigger tests 2023-10-27 07:29:52

* trigger tests 2023-10-27 07:36:14

* trigger tests 2023-11-02 08:52:22

* trigger tests 2023-11-03 10:01:22

* trigger tests 2023-11-03 10:09:42

* trigger tests 2023-11-06 06:19:02

* trigger tests 2023-11-15 06:42:20

* added object pad in cpan

* added uuid in cpan

* added uuid in cpan- removing additional data::uuid

* missing comma added

---------

Co-authored-by: Hani Kh <108520819+hani-deriv@users.noreply.github.com>
Co-authored-by: chylli-deriv <chylli@binary.com>
  • Loading branch information
3 people committed Nov 20, 2023
1 parent e03d69a commit 2badae1
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 18 deletions.
7 changes: 5 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Revision history for Perl module Mojo::WebSocketProxy
{{$NEXT}}
- Move Mojo::WebSocketProxy::Backend::JobAsync and Mojo::WebSocketProxy::Backend::ConsumerGroups out

{{$NEXT}}
0.15 2023-10-27 14:29:50+08:00 Asia/Shanghai
-Logger Wrapper added to Proxy for logging context with request

0.14
- Move Mojo::WebSocketProxy::Backend::JobAsync and Mojo::WebSocketProxy::Backend::ConsumerGroups out
- Add support for separating messages to different channels with
different timeout values for each channel.
- Increase minimum Perl version from 5.014 to 5.024 for the module.
Expand Down
26 changes: 16 additions & 10 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.029.
use strict;
use warnings;

use 5.014000;
use 5.024;

use ExtUtils::MakeMaker 7.1101;

Expand All @@ -14,24 +14,25 @@ my %WriteMakefileArgs = (
},
"DISTNAME" => "Mojo-WebSocketProxy",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.014000",
"MIN_PERL_VERSION" => "5.024",
"NAME" => "Mojo::WebSocketProxy",
"PREREQ_PM" => {
"Class::Method::Modifiers" => 0,
"Data::UUID" => 0,
"DataDog::DogStatsd::Helper" => "0.05",
"Future" => "0.36",
"Future::Mojo" => "0.004",
"IO::Async::Loop::Mojo" => 0,
"JSON::MaybeUTF8" => 0,
"Job::Async" => 0,
"Log::Any" => 0,
"Mojo::Redis2" => 0,
"MojoX::JSON::RPC" => 0,
"Mojolicious" => "7.29",
"Scalar::Util" => 0,
"Syntax::Keyword::Try" => "0.04",
"Unicode::Normalize" => "1.25",
"curry" => "1.001",
"indirect" => 0,
"Mojo::Redis2" => 0,
"Data::UUID" => 0
"indirect" => 0
},
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
Expand All @@ -46,9 +47,10 @@ my %WriteMakefileArgs = (
"Test::Mojo" => 0,
"Test::More" => "0.98",
"Test::Simple" => "0.44",
"Test::TCP" => 0
"Test::TCP" => 0,
"Test::Warnings" => 0
},
"VERSION" => "0.13",
"VERSION" => "0.15",
"test" => {
"TESTS" => "t/*.t"
}
Expand All @@ -57,6 +59,7 @@ my %WriteMakefileArgs = (

my %FallbackPrereqs = (
"Class::Method::Modifiers" => 0,
"Data::UUID" => 0,
"DataDog::DogStatsd::Helper" => "0.05",
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
Expand All @@ -66,11 +69,13 @@ my %FallbackPrereqs = (
"IO::Handle" => 0,
"IPC::Open3" => 0,
"JSON::MaybeUTF8" => 0,
"Job::Async" => 0,
"Log::Any" => 0,
"Mojo::Redis2" => 0,
"MojoX::JSON::RPC" => 0,
"Mojolicious" => "7.29",
"Path::Tiny" => 0,
"Scalar::Util" => 0,
"Syntax::Keyword::Try" => "0.04",
"Test::CheckDeps" => "0.010",
"Test::Fatal" => 0,
"Test::MockModule" => 0,
Expand All @@ -79,6 +84,7 @@ my %FallbackPrereqs = (
"Test::More" => "0.98",
"Test::Simple" => "0.44",
"Test::TCP" => 0,
"Test::Warnings" => 0,
"Unicode::Normalize" => "1.25",
"curry" => "1.001",
"indirect" => 0
Expand Down
2 changes: 2 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ requires 'perl', '5.024';
requires 'Mojo::Redis2';
requires 'Data::UUID';
requires 'Log::Any';
requires 'Object::Pad';
requires 'UUID::Tiny';

on configure => sub {
requires 'ExtUtils::MakeMaker', '7.1101';
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/WebSocketProxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Mojo::WebSocketProxy;
use strict;
use warnings;

our $VERSION = '0.13';
our $VERSION = '0.15';

1;

Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/WebSocketProxy/Dispatcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ use Mojo::WebSocketProxy::Config;

use Class::Method::Modifiers;

use JSON::MaybeUTF8 qw(:v1);
use JSON::MaybeUTF8 qw(:v1);
use Unicode::Normalize ();
use Future::Mojo 0.004; # ->new_timeout
use Future::Utils qw(fmap);
use Scalar::Util qw(blessed);
use Scalar::Util qw(blessed);
use Encode;
use DataDog::DogStatsd::Helper qw(stats_inc);

use constant TIMEOUT => $ENV{MOJO_WEBSOCKETPROXY_TIMEOUT} || 15;
use Mojo::WebSocketProxy::RequestLogger;

## VERSION
around 'send' => sub {
Expand Down Expand Up @@ -51,7 +52,6 @@ sub open_connection {

my $log = $c->app->log;
$log->debug("accepting a websocket connection from " . $c->tx->remote_address);

# Enable permessage-deflate
$c->tx->with_compression;

Expand Down Expand Up @@ -123,6 +123,7 @@ sub on_message {
my $req_storage = {};
$req_storage->{args} = $args;

$req_storage->{logger} = Mojo::WebSocketProxy::RequestLogger->new;
# We still want to run any hooks even for invalid requests.
if (my $err = Mojo::WebSocketProxy::Parser::parse_req($c, $req_storage)) {
$c->send({json => $err}, $req_storage);
Expand Down

0 comments on commit 2badae1

Please sign in to comment.