Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update!: changed the whole of APIs #20

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ hs_err_pid*

# Directories
target/
test-results-native/

# OS generating files
.DS_Store
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/github/sttk/sabi/AsyncGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* AsyncGroup class.
* Copyright (C) 2023 Takayuki Sato. All Rights Reserved.
*/
package com.github.sttk.sabi;

import com.github.sttk.sabi.errs.Err;

import java.util.Map;
import java.util.HashMap;

/**
* {@code AsyncGroup} is the inferface to execute added {@link Runner}(s)
* asynchronously.
* <p>
* The method Add is to add target {@link Runner}(s).
* This interface is used as an argument of {@link DaxSrc#setup}, {@link
* DaxConn#commit}, and {@link DaxConn#rollback}.
*/
public interface AsyncGroup {

/**
* {@code RunnerFailed} is an error reason which indicates that a {@link
* Runner} failed.
*/
record RunnerFailed() {}

/**
* {@code RunnerInterrupted} is an error reason which indicates that a {@link
* Runner}'s thread is interrupted.
*/
record RunnerInterrupted() {}

/**
* Adds a runner to be run asynchronously.
*
* @param runner A {@link Runner} object.
*/
void add(Runner runner);
}
30 changes: 30 additions & 0 deletions src/main/java/com/github/sttk/sabi/Dax.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Dax class.
* Copyright (C) 2022-2023 Takayuki Sato. All Rights Reserved.
*/
package com.github.sttk.sabi;

import com.github.sttk.sabi.errs.Err;

/**
* {@code Dax} is the interface for a set of data access methods.
*
* This interface is inherited by dax implementations for data stores, and
* each dax implementation defines data access methods to each data store.
* In data access methods, {@link DaxConn} instances conected to data stores
* can be obtained with {@link #getDaxConn} method.
*/
public interface Dax {

/**
* Gets a {@link DaxConn} instance associated with the argument name.
* The name is same as what was registered with {@link DaxSrc} using
* {@link Sabi#uses} method.
*
* @param <C> The type of a {@link DaxConn}.
* @param name A name of a {@link DaxConn}.
* @return A {@link DaxConn} instance.
* @throws Err If getting a {@link DaxConn} fails.
*/
<C extends DaxConn> C getDaxConn(String name) throws Err;
}
Loading
Loading