Skip to content

bunjik/asyncutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Build Status License Coverage Status

asyncutil

RxJava based asynchronous processing utility.

概要

リスト処理を容易に非同期化するためのユーティリティ。

利用ケース

  1. 非同期にデータを順次処理したい場合
  2. 大量のデータを順次処理したい場合

Example code

1. process class

public class DbExportProcess extends AsyncProcess<String> {

    private Connection conn = null;

    // Async execure process.
    @Override
    public void execute() {
        conn = DriverManager.getConnection("jdbc:xxxxx:xxx");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM TEST;");
        while (rs.next()) {
            // emit value
            append(re.getString("name"));
        }
    }

    @Overide
    public void close() throws IOExcption {
      if (conn != null) {
          conn.close();
      }
    }
}

2. run processs

DbExportProcess proc = new DbExportProcess();
try (ClosableResult rersults : proc.run()) {
    for (String name : results) {

    }
} catch (IOException ioe) {
    ioe.printStackTrace();
}

About

RxJava based asynchronous processing utility

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages