root/perl/lib/JLog/Writer.pm

Revision 81ac86a15e3940ff0b787698853fb6a6157f800b, 2.4 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 7 years ago)

initial import with Ecelerity bits removed and some autoconf glue added in. Could certainly use some work on the build/install. Needs shared lib support for multiple platforms

  • Property mode set to 100644
Line 
1 package JLog::Writer;
2
3 require DynaLoader;
4
5 use JLog;
6 use strict;
7
8 use vars qw/@ISA/;
9
10 @ISA = qw(Exporter DynaLoader JLog);
11
12 1;
13 __END__
14
15 =head1 NAME
16
17 JLog::Writer - Perl extension for writing to a jlog journal.
18
19 =head1 SUMMARY
20
21   use JLog::Writer;
22   use Fcntl qw/:DEFAULT/;
23  
24   my $sub = "testsubscriber";
25   my $log = "foo.jlog";
26  
27   # open a log - this respects stander Fcntl flags
28   my $w = JLog::Writer->new($log, O_CREAT);
29  
30   # add a subscriber - without this there is danger that
31   # a log may be expired without the unnamed subscriber
32   # stating its intention to read.
33   $w->add_subscriber($sub);
34  
35   # open for writing
36   $w->open;
37  
38   foreach (1 ... 3) {
39     # write to the queue
40     $w->write("foo $_");
41   }
42   # close the queue
43   $w->close;
44
45 =head1 DESCRIPTION
46
47 JLog::Writer allows you to access a jlog queue for writing.
48
49 =head1 INTERFACE
50
51 =head2 Constructor
52
53 =head3 new
54
55   $w = JLog::Writer->new( $path_to_jlog, [ $flags [, $size ] ] );
56
57 Instantiates a JLog writer object associated with the JLog directory.
58
59 =over 4
60
61 =item $path_to_jlog
62
63 The directory for the JLog queue.
64
65 =item $flags
66
67 Optional flags, from 'Fcntl'.  The default is O_CREAT.
68
69 =item $size
70
71 Optional size of the individual journal files.
72
73 =back
74
75 =head2 Subscriber Management
76
77 These functions are inherited from JLog
78
79 =head3 add_subscriber
80
81   $w->add_subscriber( $name, [ $flag ] );
82
83 Add a subscriber to the JLog queue.
84
85 =over 4
86
87 =item $name
88
89 The name of the subscriber.
90
91 =item $flag
92
93 An optional flag dictating where the subscriber should be marked interested
94 from.  The default is JLog::JLOG_BEGIN.  The other available option is
95 JLog::JLOG_END.
96
97 =back
98
99 =head3 remove_subscriber
100
101   $w->remove_subscriber ( $name );
102
103 Remove a subscriber to the JLog queue.
104
105 =over 4
106
107 =item $name
108
109 The name of the subscriber.
110
111 =back
112
113 =head2 Writing to the Queue
114
115 =head3 open
116
117   $w->open();
118
119 Opens the JLog for writing.
120
121 =head3 write
122
123   $w->write( $message );
124
125 Write a message to the JLog.
126
127 =over 4
128
129 =item $message
130
131 The message to write.
132
133 =back
134
135 =head2 Internals
136
137 =head3 alter_journal_size
138
139   $w->alter_journal_size( $size );
140
141 Set the size of the individual journal files.
142
143 =over 4
144
145 =item $size
146
147 The desired size in bytes.
148
149 =back
150
151 =head3 raw_size
152
153   $size = $w->raw_size;
154
155 The size of the existing journal (including checkpointed but unpurged messages
156 in the current journal file), in bytes.
157
158 =head1 SEE ALSO
159
160 JLog
161 JLog::Reader
162
163 =head1 COPYRIGHT AND LICENSE
164
165 Copyright (C) 2006 by OmniTI, Inc.
166
167 =cut
168
Note: See TracBrowser for help on using the browser.