beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eugene Kirpichov (JIRA)" <>
Subject [jira] [Commented] (BEAM-702) Simple pattern for per-bundle and per-DoFn Closeable resources
Date Mon, 03 Oct 2016 18:47:20 GMT


Eugene Kirpichov commented on BEAM-702:

CC: [~tgroh]

> Simple pattern for per-bundle and per-DoFn Closeable resources
> --------------------------------------------------------------
>                 Key: BEAM-702
>                 URL:
>             Project: Beam
>          Issue Type: Improvement
>            Reporter: Eugene Kirpichov
> Dealing with Closeable resources inside a processElement call is easy: simply use try-with-resources.
> However, bundle- or DoFn-scoped resources, such as long-lived database connections, are
less convenient to deal with: you have to open them in startBundle and conditionally close
in finishBundle (likewise setup/teardown), taking special care if there's multiple resources
to close all of them.
> Perhaps we should provide something like Guava's Closer to DoFn's
Ideally, the user would need to only write a startBundle() or setup() method, but not write
finishBundle() or teardown() - resources would be closed automatically.

This message was sent by Atlassian JIRA

View raw message