{
    "content": [
        {
            "type": "text",
            "text": "# DBD::Gofer::Transport::corostream (perldoc)\n\n## NAME\n\nDBD::Gofer::Transport::corostream - Async DBD::Gofer stream transport using Coro and AnyEvent\n\n## SYNOPSIS\n\nDBIAUTOPROXY=\"dbi:Gofer:transport=corostream\" perl some-perl-script-using-dbi.pl\nor\n$dsn = ...; # the DSN for the driver and database you want to use\n$dbh = DBI->connect(\"dbi:Gofer:transport=corostream;dsn=$dsn\", ...);\n\n## DESCRIPTION\n\nThe *BIG WIN* from using Coro is that it enables the use of existing DBI frameworks like\nDBIx::Class.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **KNOWN ISSUES AND LIMITATIONS**\n- **STATUS**\n- **AUTHOR**\n- **LICENCE AND COPYRIGHT**\n- **SEE ALSO**\n- **APPENDIX**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "DBD::Gofer::Transport::corostream",
        "section": "",
        "mode": "perldoc",
        "summary": "DBD::Gofer::Transport::corostream - Async DBD::Gofer stream transport using Coro and AnyEvent",
        "synopsis": "DBIAUTOPROXY=\"dbi:Gofer:transport=corostream\" perl some-perl-script-using-dbi.pl\nor\n$dsn = ...; # the DSN for the driver and database you want to use\n$dbh = DBI->connect(\"dbi:Gofer:transport=corostream;dsn=$dsn\", ...);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "KNOWN ISSUES AND LIMITATIONS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "STATUS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "LICENCE AND COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "APPENDIX",
                "lines": 62,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "DBD::Gofer::Transport::corostream - Async DBD::Gofer stream transport using Coro and AnyEvent\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "DBIAUTOPROXY=\"dbi:Gofer:transport=corostream\" perl some-perl-script-using-dbi.pl\n\nor\n\n$dsn = ...; # the DSN for the driver and database you want to use\n$dbh = DBI->connect(\"dbi:Gofer:transport=corostream;dsn=$dsn\", ...);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The *BIG WIN* from using Coro is that it enables the use of existing DBI frameworks like\nDBIx::Class.\n",
                "subsections": []
            },
            "KNOWN ISSUES AND LIMITATIONS": {
                "content": "- Uses Coro::Select so alters CORE::select globally\nParent class probably needs refactoring to enable a more encapsulated approach.\n\n- Doesn't prevent multiple concurrent requests\nProbably just needs a per-connection semaphore\n\n- Coro has many caveats. Caveat emptor.\n",
                "subsections": []
            },
            "STATUS": {
                "content": "THIS IS CURRENTLY JUST A PROOF-OF-CONCEPT IMPLEMENTATION FOR EXPERIMENTATION.\n\nPlease note that I have no plans to develop this code further myself. I'd very much welcome\ncontributions. Interested? Let me know!\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Tim Bunce, <http://www.tim.bunce.name>\n",
                "subsections": []
            },
            "LICENCE AND COPYRIGHT": {
                "content": "Copyright (c) 2010, Tim Bunce, Ireland. All rights reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See perlartistic.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "DBD::Gofer::Transport::stream\n\nDBD::Gofer\n",
                "subsections": []
            },
            "APPENDIX": {
                "content": "Example code:\n\n#!perl\n\nuse strict;\nuse warnings;\nuse Time::HiRes qw(time);\n\nBEGIN { $ENV{PERLANYEVENTSTRICT} = 1; $ENV{PERLANYEVENTVERBOSE} = 1; }\n\nuse AnyEvent;\n\nBEGIN { $ENV{DBITRACE} = 0; $ENV{DBIGOFERTRACE} = 0; $ENV{DBDGOFERTRACE} = 0; };\n\nuse DBI;\n\n$ENV{DBIAUTOPROXY} = 'dbi:Gofer:transport=corostream';\n\nmy $ticker = AnyEvent->timer( after => 0, interval => 0.1, cb => sub {\nwarn sprintf \"-tick- %.2f\\n\", time\n} );\n\nwarn \"connecting...\\n\";\nmy $dbh = DBI->connect(\"dbi:NullP:\");\nwarn \"...connected\\n\";\n\nfor (1..3) {\nwarn \"entering DBI...\\n\";\n$dbh->do(\"sleep 0.3\"); # pseudo-sql understood by the DBD::NullP driver\nwarn \"...returned\\n\";\n}\n\nwarn \"done.\";\n\nExample output:\n\n$ perl corogofer.pl\nconnecting...\n-tick- 1293631437.14\n-tick- 1293631437.14\n...connected\nentering DBI...\n-tick- 1293631437.25\n-tick- 1293631437.35\n-tick- 1293631437.45\n-tick- 1293631437.55\n...returned\nentering DBI...\n-tick- 1293631437.66\n-tick- 1293631437.76\n-tick- 1293631437.86\n...returned\nentering DBI...\n-tick- 1293631437.96\n-tick- 1293631438.06\n-tick- 1293631438.16\n...returned\ndone. at corogofer.pl line 39.\n\nYou can see that the timer callback is firing while the code 'waits' inside the do() method for\nthe response from the database. Normally that would block.\n",
                "subsections": []
            }
        }
    }
}