| 1 | package Langertha::Role::KeepAlive; | ||||||||||
| 2 | # ABSTRACT: Role for engines that support keep-alive duration | ||||||||||
| 3 | 12 | our $VERSION = '0.502'; | |||||||||
| 4 | 12 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 12 | has keep_alive => ( | |||||||||
| 7 | isa => 'Str', | ||||||||||
| 8 | is => 'ro', | ||||||||||
| 9 | predicate => 'has_keep_alive', | ||||||||||
| 10 | ); | ||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 12 | has no_keep_alive => ( | |||||||||
| 14 | isa => 'Bool', | ||||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | default => 0, | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | sub get_keep_alive { | ||||||||||
| 21 | 6 | ▶ | my ( $self ) = @_; | ||||||||
|
Subroutine
get_keep_alive: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||
| 22 | 6 | ▶ | return '0' if $self->no_keep_alive; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 6 | ▶ | return $self->keep_alive if $self->has_keep_alive; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 6 | return undef; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 12 | 1; | |||||||||
| 30 | |||||||||||
| 31 | __END__ | ||||||||||
| 32 | |||||||||||
| 33 | =pod | ||||||||||
| 34 | |||||||||||
| 35 | =encoding UTF-8 | ||||||||||
| 36 | |||||||||||
| 37 | =head1 NAME | ||||||||||
| 38 | |||||||||||
| 39 | Langertha::Role::KeepAlive - Role for engines that support keep-alive duration | ||||||||||
| 40 | |||||||||||
| 41 | =head1 VERSION | ||||||||||
| 42 | |||||||||||
| 43 | version 0.502 | ||||||||||
| 44 | |||||||||||
| 45 | =head2 keep_alive | ||||||||||
| 46 | |||||||||||
| 47 | keep_alive => '5m' | ||||||||||
| 48 | keep_alive => '-1' # keep forever | ||||||||||
| 49 | |||||||||||
| 50 | Controls how long the engine keeps the model loaded in memory after a request. | ||||||||||
| 51 | Accepts duration strings such as C<5m> or C<-1> (keep forever). When not set, | ||||||||||
| 52 | the engine uses its own default. | ||||||||||
| 53 | |||||||||||
| 54 | See also C<no_keep_alive> for explicitly unloading the model after each request. | ||||||||||
| 55 | |||||||||||
| 56 | =head2 no_keep_alive | ||||||||||
| 57 | |||||||||||
| 58 | no_keep_alive => 1 | ||||||||||
| 59 | |||||||||||
| 60 | When true, the model is unloaded from memory immediately after each request. | ||||||||||
| 61 | Equivalent to setting C<keep_alive =E<gt> '0'> but more explicit. | ||||||||||
| 62 | |||||||||||
| 63 | =head2 get_keep_alive | ||||||||||
| 64 | |||||||||||
| 65 | Returns the effective keep-alive value: C<'0'> if C<no_keep_alive> is set, | ||||||||||
| 66 | the C<keep_alive> value if provided, or C<undef> if neither is set (letting | ||||||||||
| 67 | the engine use its default). | ||||||||||
| 68 | |||||||||||
| 69 | =head1 SEE ALSO | ||||||||||
| 70 | |||||||||||
| 71 | =over | ||||||||||
| 72 | |||||||||||
| 73 | =item * L<Langertha::Engine::Ollama> - Engine that composes this role | ||||||||||
| 74 | |||||||||||
| 75 | =back | ||||||||||
| 76 | |||||||||||
| 77 | =head1 SUPPORT | ||||||||||
| 78 | |||||||||||
| 79 | =head2 Issues | ||||||||||
| 80 | |||||||||||
| 81 | Please report bugs and feature requests on GitHub at | ||||||||||
| 82 | L<https://github.com/Getty/langertha/issues>. | ||||||||||
| 83 | |||||||||||
| 84 | =head2 IRC | ||||||||||
| 85 | |||||||||||
| 86 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||
| 87 | |||||||||||
| 88 | =head1 CONTRIBUTING | ||||||||||
| 89 | |||||||||||
| 90 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||
| 91 | |||||||||||
| 92 | =head1 AUTHOR | ||||||||||
| 93 | |||||||||||
| 94 | Torsten Raudssus <getty@cpan.org> | ||||||||||
| 95 | |||||||||||
| 96 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 97 | |||||||||||
| 98 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||
| 99 | |||||||||||
| 100 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 101 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||