Zing/Types.pm

filter: Statementstmt 100% 47 / 47 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 52 / 52 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Zing/Timer.pm ↑ Summary
1 package Zing::Types;
2  
3 49 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 49 ▶use Data::Object::Types::Keywords;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 49 ▶use base 'Data::Object::Types::Library';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 49 extends 'Types::Standard';
13  
14 49 our $VERSION = '0.11'; # VERSION
15  
16 49 register {
17 name => 'Channel',
18 parent => 'Object',
19 validation => is_instance_of('Zing::Channel'),
20 };
21  
22 49 register {
23 name => 'Data',
24 parent => 'Object',
25 validation => is_instance_of('Zing::Data'),
26 };
27  
28 49 register {
29 name => 'Domain',
30 parent => 'Object',
31 validation => is_instance_of('Zing::Domain'),
32 };
33  
34 49 register {
35 name => 'Error',
36 parent => 'Object',
37 validation => is_instance_of('Zing::Error'),
38 };
39  
40 49 register {
41 name => 'Flow',
42 parent => 'Object',
43 validation => is_instance_of('Zing::Flow'),
44 };
45  
46 49 register {
47 name => 'Fork',
48 parent => 'Object',
49 validation => is_instance_of('Zing::Fork'),
50 };
51  
52 49 declare 'Interupt',
53 as Enum([qw(CHLD HUP INT QUIT TERM USR1 USR2)]);
54  
55 49 register {
56 name => 'Kernel',
57 parent => 'Object',
58 validation => is_instance_of('Zing::Kernel'),
59 };
60  
61 49 register {
62 name => 'KeyVal',
63 parent => 'Object',
64 validation => is_instance_of('Zing::KeyVal'),
65 };
66  
67 49 register {
68 name => 'Logic',
69 parent => 'Object',
70 validation => is_instance_of('Zing::Logic'),
71 };
72  
73 49 register {
74 name => 'Loop',
75 parent => 'Object',
76 validation => is_instance_of('Zing::Loop'),
77 };
78  
79 49 register {
80 name => 'Logger',
81 parent => 'Object',
82 validation => is_instance_of('FlightRecorder'),
83 };
84  
85 49 register {
86 name => 'Mailbox',
87 parent => 'Object',
88 validation => is_instance_of('Zing::Mailbox'),
89 };
90  
91 49 register {
92 name => 'Node',
93 parent => 'Object',
94 validation => is_instance_of('Zing::Node'),
95 };
96  
97 49 register {
98 name => 'Poll',
99 parent => 'Object',
100 validation => is_instance_of('Zing::Poll'),
101 };
102  
103 49 register {
104 name => 'Process',
105 parent => 'Object',
106 validation => is_instance_of('Zing::Process'),
107 };
108  
109 49 register {
110 name => 'PubSub',
111 parent => 'Object',
112 validation => is_instance_of('Zing::PubSub'),
113 };
114  
115 49 register {
116 name => 'Queue',
117 parent => 'Object',
118 validation => is_instance_of('Zing::Queue'),
119 };
120  
121 49 register {
122 name => 'Registry',
123 parent => 'Object',
124 validation => is_instance_of('Zing::Registry'),
125 };
126  
127 49 register {
128 name => 'Redis',
129 parent => 'Object',
130 validation => is_instance_of('Redis'),
131 };
132  
133 49 register {
134 name => 'Repo',
135 parent => 'Object',
136 validation => is_instance_of('Zing::Repo'),
137 };
138  
139 49 declare 'Schedule',
140 as Tuple([Str(), ArrayRef([Str()]), HashRef()]);
141  
142 49 declare 'Scheme',
143 as Tuple([Str(), ArrayRef(), Int()]);
144  
145 49 register {
146 name => 'Server',
147 parent => 'Object',
148 validation => is_instance_of('Zing::Server'),
149 };
150  
151 49 register {
152 name => 'Space',
153 parent => 'Object',
154 validation => is_instance_of('Data::Object::Space'),
155 };
156  
157 49 register {
158 name => 'Store',
159 parent => 'Object',
160 validation => is_instance_of('Zing::Store'),
161 };
162  
163 49 register {
164 name => 'Task',
165 parent => 'Object',
166 validation => is_instance_of('Zing::Task'),
167 };
168  
169 49 register {
170 name => 'Watcher',
171 parent => 'Object',
172 validation => is_instance_of('Zing::Watcher'),
173 };
174  
175 49 register {
176 name => 'Worker',
177 parent => 'Object',
178 validation => is_instance_of('Zing::Worker'),
179 };
180  
181 49 register {
182 name => 'Zing',
183 parent => 'Object',
184 validation => is_instance_of('Zing'),
185 };
186  
187 49 1;
188 =encoding utf8
189  
190 =head1 NAME
191  
192 Zing::Types - Type Library
193  
194 =cut
195  
196 =head1 ABSTRACT
197  
198 Type Library
199  
200 =cut
201  
202 =head1 SYNOPSIS
203  
204 package main;
205  
206 use Zing::Types;
207  
208 1;
209  
210 =cut
211  
212 =head1 DESCRIPTION
213  
214 This package provides type constraint for the L<Zing> process management
215 system.
216  
217 =cut
218  
219 =head1 LIBRARIES
220  
221 This package uses type constraints from:
222  
223 L<Types::Standard>
224  
225 =cut
226  
227 =head1 CONSTRAINTS
228  
229 This package declares the following type constraints:
230  
231 =cut
232  
233 =head2 channel
234  
235 Channel
236  
237 This type is defined in the L<Zing::Types> library.
238  
239 =over 4
240  
241 =item channel parent
242  
243 Object
244  
245 =back
246  
247 =over 4
248  
249 =item channel composition
250  
251 InstanceOf["Zing::Channel"]
252  
253 =back
254  
255 =over 4
256  
257 =item channel example #1
258  
259 # given: synopsis
260  
261 use Zing::Channel;
262  
263 my $chan = Zing::Channel->new(name => 'share');
264  
265 =back
266  
267 =cut
268  
269 =head2 data
270  
271 Data
272  
273 This type is defined in the L<Zing::Types> library.
274  
275 =over 4
276  
277 =item data parent
278  
279 Object
280  
281 =back
282  
283 =over 4
284  
285 =item data composition
286  
287 InstanceOf["Zing::Data"]
288  
289 =back
290  
291 =over 4
292  
293 =item data example #1
294  
295 # given: synopsis
296  
297 use Zing::Data;
298 use Zing::Process;
299  
300 my $data = Zing::Data->new(process => Zing::Process->new);
301  
302 =back
303  
304 =cut
305  
306 =head2 domain
307  
308 Domain
309  
310 This type is defined in the L<Zing::Types> library.
311  
312 =over 4
313  
314 =item domain parent
315  
316 Object
317  
318 =back
319  
320 =over 4
321  
322 =item domain composition
323  
324 InstanceOf["Zing::Domain"]
325  
326 =back
327  
328 =over 4
329  
330 =item domain example #1
331  
332 # given: synopsis
333  
334 use Zing::Domain;
335  
336 my $domain = Zing::Domain->new(name => 'exchange');
337  
338 =back
339  
340 =cut
341  
342 =head2 flow
343  
344 Flow
345  
346 This type is defined in the L<Zing::Types> library.
347  
348 =over 4
349  
350 =item flow parent
351  
352 Object
353  
354 =back
355  
356 =over 4
357  
358 =item flow composition
359  
360 InstanceOf["Zing::Flow"]
361  
362 =back
363  
364 =over 4
365  
366 =item flow example #1
367  
368 # given: synopsis
369  
370 use Zing::Flow;
371  
372 my $flow = Zing::Flow->new(name => 'step_1', code => sub {1});
373  
374 =back
375  
376 =cut
377  
378 =head2 fork
379  
380 Fork
381  
382 This type is defined in the L<Zing::Types> library.
383  
384 =over 4
385  
386 =item fork parent
387  
388 Object
389  
390 =back
391  
392 =over 4
393  
394 =item fork composition
395  
396 InstanceOf["Zing::Fork"]
397  
398 =back
399  
400 =over 4
401  
402 =item fork example #1
403  
404 # given: synopsis
405  
406 use Zing::Fork;
407 use Zing::Process;
408  
409 my $scheme = ['MyApp', [], 1];
410 my $fork = Zing::Fork->new(scheme => $scheme, parent => Zing::Process->new);
411  
412 =back
413  
414 =cut
415  
416 =head2 interupt
417  
418 Interupt
419  
420 This type is defined in the L<Zing::Types> library.
421  
422 =over 4
423  
424 =item interupt composition
425  
426 Enum[qw(CHLD HUP INT QUIT TERM USR1 USR2)]
427  
428 =back
429  
430 =over 4
431  
432 =item interupt example #1
433  
434 # given: synopsis
435  
436 'QUIT'
437  
438 =back
439  
440 =cut
441  
442 =head2 kernel
443  
444 Kernel
445  
446 This type is defined in the L<Zing::Types> library.
447  
448 =over 4
449  
450 =item kernel parent
451  
452 Object
453  
454 =back
455  
456 =over 4
457  
458 =item kernel composition
459  
460 InstanceOf["Zing::Kernel"]
461  
462 =back
463  
464 =over 4
465  
466 =item kernel example #1
467  
468 # given: synopsis
469  
470 use Zing::Kernel;
471  
472 my $kernel = Zing::Kernel->new(scheme => ['MyApp', [], 1]);
473  
474 =back
475  
476 =cut
477  
478 =head2 keyval
479  
480 KeyVal
481  
482 This type is defined in the L<Zing::Types> library.
483  
484 =over 4
485  
486 =item keyval parent
487  
488 Object
489  
490 =back
491  
492 =over 4
493  
494 =item keyval composition
495  
496 InstanceOf["Zing::KeyVal"]
497  
498 =back
499  
500 =over 4
501  
502 =item keyval example #1
503  
504 # given: synopsis
505  
506 use Zing::KeyVal;
507  
508 my $keyval = Zing::KeyVal->new(name => 'notes');
509  
510 =back
511  
512 =cut
513  
514 =head2 logger
515  
516 Logger
517  
518 This type is defined in the L<Zing::Types> library.
519  
520 =over 4
521  
522 =item logger parent
523  
524 Object
525  
526 =back
527  
528 =over 4
529  
530 =item logger composition
531  
532 InstanceOf["Zing::Logger"]
533  
534 =back
535  
536 =over 4
537  
538 =item logger example #1
539  
540 # given: synopsis
541  
542 use FlightRecorder;
543  
544 my $logger = FlightRecorder->new;
545  
546 =back
547  
548 =cut
549  
550 =head2 logic
551  
552 Logic
553  
554 This type is defined in the L<Zing::Types> library.
555  
556 =over 4
557  
558 =item logic parent
559  
560 Object
561  
562 =back
563  
564 =over 4
565  
566 =item logic composition
567  
568 InstanceOf["Zing::Logic"]
569  
570 =back
571  
572 =over 4
573  
574 =item logic example #1
575  
576 # given: synopsis
577  
578 use Zing::Logic;
579 use Zing::Process;
580  
581 my $process = Zing::Process->new;
582 my $logic = Zing::Logic->new(process => $process);
583  
584 =back
585  
586 =cut
587  
588 =head2 loop
589  
590 Loop
591  
592 This type is defined in the L<Zing::Types> library.
593  
594 =over 4
595  
596 =item loop parent
597  
598 Object
599  
600 =back
601  
602 =over 4
603  
604 =item loop composition
605  
606 InstanceOf["Zing::Loop"]
607  
608 =back
609  
610 =over 4
611  
612 =item loop example #1
613  
614 # given: synopsis
615  
616 use Zing::Flow;
617 use Zing::Loop;
618  
619 my $loop = Zing::Loop->new(
620 flow => Zing::Flow->new(name => 'init', code => sub {1})
621 );
622  
623 =back
624  
625 =cut
626  
627 =head2 mailbox
628  
629 Mailbox
630  
631 This type is defined in the L<Zing::Types> library.
632  
633 =over 4
634  
635 =item mailbox parent
636  
637 Object
638  
639 =back
640  
641 =over 4
642  
643 =item mailbox composition
644  
645 InstanceOf["Zing::Mailbox"]
646  
647 =back
648  
649 =over 4
650  
651 =item mailbox example #1
652  
653 # given: synopsis
654  
655 use Zing::Mailbox;
656 use Zing::Process;
657  
658 my $mailbox = Zing::Mailbox->new(process => Zing::Process->new);
659  
660 =back
661  
662 =cut
663  
664 =head2 node
665  
666 Node
667  
668 This type is defined in the L<Zing::Types> library.
669  
670 =over 4
671  
672 =item node parent
673  
674 Object
675  
676 =back
677  
678 =over 4
679  
680 =item node composition
681  
682 InstanceOf["Zing::Node"]
683  
684 =back
685  
686 =over 4
687  
688 =item node example #1
689  
690 # given: synopsis
691  
692 use Zing::Node;
693  
694 my $node = Zing::Node->new;
695  
696 =back
697  
698 =cut
699  
700 =head2 poll
701  
702 Poll
703  
704 This type is defined in the L<Zing::Types> library.
705  
706 =over 4
707  
708 =item poll parent
709  
710 Object
711  
712 =back
713  
714 =over 4
715  
716 =item poll composition
717  
718 InstanceOf["Zing::Poll"]
719  
720 =back
721  
722 =over 4
723  
724 =item poll example #1
725  
726 # given: synopsis
727  
728 use Zing::Poll;
729 use Zing::KeyVal;
730  
731 my $keyval = Zing::KeyVal->new(name => 'notes');
732 my $poll = Zing::Poll->new(name => 'last-week', repo => $keyval);
733  
734 =back
735  
736 =cut
737  
738 =head2 process
739  
740 Process
741  
742 This type is defined in the L<Zing::Types> library.
743  
744 =over 4
745  
746 =item process parent
747  
748 Object
749  
750 =back
751  
752 =over 4
753  
754 =item process composition
755  
756 InstanceOf["Zing::Process"]
757  
758 =back
759  
760 =over 4
761  
762 =item process example #1
763  
764 # given: synopsis
765  
766 use Zing::Process;
767  
768 my $process = Zing::Process->new;
769  
770 =back
771  
772 =cut
773  
774 =head2 pubsub
775  
776 PubSub
777  
778 This type is defined in the L<Zing::Types> library.
779  
780 =over 4
781  
782 =item pubsub parent
783  
784 Object
785  
786 =back
787  
788 =over 4
789  
790 =item pubsub composition
791  
792 InstanceOf["Zing::PubSub"]
793  
794 =back
795  
796 =over 4
797  
798 =item pubsub example #1
799  
800 # given: synopsis
801  
802 use Zing::PubSub;
803  
804 my $pubsub = Zing::PubSub->new(name => 'tasks');
805  
806 =back
807  
808 =cut
809  
810 =head2 queue
811  
812 Queue
813  
814 This type is defined in the L<Zing::Types> library.
815  
816 =over 4
817  
818 =item queue parent
819  
820 Object
821  
822 =back
823  
824 =over 4
825  
826 =item queue composition
827  
828 InstanceOf["Zing::Queue"]
829  
830 =back
831  
832 =over 4
833  
834 =item queue example #1
835  
836 # given: synopsis
837  
838 use Zing::Queue;
839  
840 my $queue = Zing::Queue->new(name => 'tasks');
841  
842 =back
843  
844 =cut
845  
846 =head2 redis
847  
848 Redis
849  
850 This type is defined in the L<Zing::Types> library.
851  
852 =over 4
853  
854 =item redis parent
855  
856 Object
857  
858 =back
859  
860 =over 4
861  
862 =item redis composition
863  
864 InstanceOf["Zing::Redis"]
865  
866 =back
867  
868 =over 4
869  
870 =item redis example #1
871  
872 # given: synopsis
873  
874 bless {}, 'Redis';
875  
876 =back
877  
878 =cut
879  
880 =head2 registry
881  
882 Registry
883  
884 This type is defined in the L<Zing::Types> library.
885  
886 =over 4
887  
888 =item registry parent
889  
890 Object
891  
892 =back
893  
894 =over 4
895  
896 =item registry composition
897  
898 InstanceOf["Zing::Registry"]
899  
900 =back
901  
902 =over 4
903  
904 =item registry example #1
905  
906 # given: synopsis
907  
908 use Zing::Process;
909 use Zing::Registry;
910  
911 my $process = Zing::Process->new;
912 my $registry = Zing::Registry->new(process => $process);
913  
914 =back
915  
916 =cut
917  
918 =head2 repo
919  
920 Repo
921  
922 This type is defined in the L<Zing::Types> library.
923  
924 =over 4
925  
926 =item repo parent
927  
928 Object
929  
930 =back
931  
932 =over 4
933  
934 =item repo composition
935  
936 InstanceOf["Zing::Repo"]
937  
938 =back
939  
940 =over 4
941  
942 =item repo example #1
943  
944 # given: synopsis
945  
946 use Zing::Repo;
947  
948 my $repo = Zing::Repo->new(name => 'repo');
949  
950 =back
951  
952 =cut
953  
954 =head2 schedule
955  
956 Schedule
957  
958 This type is defined in the L<Zing::Types> library.
959  
960 =over 4
961  
962 =item schedule composition
963  
964 Tuple[Str, ArrayRef[Str], HashRef]
965  
966 =back
967  
968 =over 4
969  
970 =item schedule example #1
971  
972 # given: synopsis
973  
974 # at 00:00 on day-of-month 1 in january
975  
976 ['0 0 1 1 *', ['task_queue'], { task => 'execute' }];
977  
978 =back
979  
980 =over 4
981  
982 =item schedule example #2
983  
984 # given: synopsis
985  
986 # at 00:00 on saturday
987  
988 ['0 0 * * SAT', ['task_queue'], { task => 'execute' }];
989  
990 =back
991  
992 =over 4
993  
994 =item schedule example #3
995  
996 # given: synopsis
997  
998 # at minute 0 (hourly)
999  
1000 ['0 * * * *', ['task_queue'], { task => 'execute' }];
1001  
1002 =back
1003  
1004 =cut
1005  
1006 =head2 scheme
1007  
1008 Scheme
1009  
1010 This type is defined in the L<Zing::Types> library.
1011  
1012 =over 4
1013  
1014 =item scheme composition
1015  
1016 Tuple[Str, ArrayRef, Int]
1017  
1018 =back
1019  
1020 =over 4
1021  
1022 =item scheme example #1
1023  
1024 # given: synopsis
1025  
1026 ['MyApp', [], 1_000];
1027  
1028 =back
1029  
1030 =cut
1031  
1032 =head2 server
1033  
1034 Server
1035  
1036 This type is defined in the L<Zing::Types> library.
1037  
1038 =over 4
1039  
1040 =item server parent
1041  
1042 Object
1043  
1044 =back
1045  
1046 =over 4
1047  
1048 =item server composition
1049  
1050 InstanceOf["Zing::Server"]
1051  
1052 =back
1053  
1054 =over 4
1055  
1056 =item server example #1
1057  
1058 # given: synopsis
1059  
1060 use Zing::Server;
1061  
1062 my $server = Zing::Server->new;
1063  
1064 =back
1065  
1066 =cut
1067  
1068 =head2 space
1069  
1070 Space
1071  
1072 This type is defined in the L<Zing::Types> library.
1073  
1074 =over 4
1075  
1076 =item space parent
1077  
1078 Object
1079  
1080 =back
1081  
1082 =over 4
1083  
1084 =item space composition
1085  
1086 InstanceOf["Zing::Space"]
1087  
1088 =back
1089  
1090 =over 4
1091  
1092 =item space example #1
1093  
1094 # given: synopsis
1095  
1096 use Data::Object::Space;
1097  
1098 Data::Object::Space->new('MyApp');
1099  
1100 =back
1101  
1102 =cut
1103  
1104 =head2 store
1105  
1106 Store
1107  
1108 This type is defined in the L<Zing::Types> library.
1109  
1110 =over 4
1111  
1112 =item store parent
1113  
1114 Object
1115  
1116 =back
1117  
1118 =over 4
1119  
1120 =item store composition
1121  
1122 InstanceOf["Zing::Store"]
1123  
1124 =back
1125  
1126 =over 4
1127  
1128 =item store example #1
1129  
1130 # given: synopsis
1131  
1132 use Zing::Store;
1133  
1134 my $store = Zing::Store->new;
1135  
1136 =back
1137  
1138 =cut
1139  
1140 =head2 watcher
1141  
1142 Watcher
1143  
1144 This type is defined in the L<Zing::Types> library.
1145  
1146 =over 4
1147  
1148 =item watcher parent
1149  
1150 Object
1151  
1152 =back
1153  
1154 =over 4
1155  
1156 =item watcher composition
1157  
1158 InstanceOf["Zing::Watcher"]
1159  
1160 =back
1161  
1162 =over 4
1163  
1164 =item watcher example #1
1165  
1166 # given: synopsis
1167  
1168 bless {}, 'Zing::Watcher';
1169  
1170 =back
1171  
1172 =cut
1173  
1174 =head2 worker
1175  
1176 Worker
1177  
1178 This type is defined in the L<Zing::Types> library.
1179  
1180 =over 4
1181  
1182 =item worker parent
1183  
1184 Object
1185  
1186 =back
1187  
1188 =over 4
1189  
1190 =item worker composition
1191  
1192 InstanceOf["Zing::Worker"]
1193  
1194 =back
1195  
1196 =over 4
1197  
1198 =item worker example #1
1199  
1200 # given: synopsis
1201  
1202 bless {}, 'Zing::Worker';
1203  
1204 =back
1205  
1206 =cut
1207  
1208 =head2 zing
1209  
1210 Zing
1211  
1212 This type is defined in the L<Zing::Types> library.
1213  
1214 =over 4
1215  
1216 =item zing parent
1217  
1218 Object
1219  
1220 =back
1221  
1222 =over 4
1223  
1224 =item zing composition
1225  
1226 InstanceOf["Zing::Zing"]
1227  
1228 =back
1229  
1230 =over 4
1231  
1232 =item zing example #1
1233  
1234 # given: synopsis
1235  
1236 use Zing;
1237  
1238 my $zing = Zing->new(scheme => ['MyApp', [], 1]);
1239  
1240 =back
1241  
1242 =cut
1243  
1244 =head1 AUTHOR
1245  
1246 Al Newkirk, C<awncorp@cpan.org>
1247  
1248 =head1 LICENSE
1249  
1250 Copyright (C) 2011-2019, Al Newkirk, et al.
1251  
1252 This is free software; you can redistribute it and/or modify it under the terms
1253 of the The Apache License, Version 2.0, as elucidated in the L<"license
1254 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
1255  
1256 =head1 PROJECT
1257  
1258 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
1259  
1260 L<Project|https://github.com/iamalnewkirk/zing>
1261  
1262 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
1263  
1264 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
1265  
1266 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
1267  
1268 L<Issues|https://github.com/iamalnewkirk/zing/issues>
1269  
1270 =cut
« Zing/Timer.pm ↑ Summary