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

Is there any way to define Array of transaction state? #3

Open
moh-esmaeilzadeh opened this issue Mar 2, 2022 · 0 comments
Open

Is there any way to define Array of transaction state? #3

moh-esmaeilzadeh opened this issue Mar 2, 2022 · 0 comments

Comments

@moh-esmaeilzadeh
Copy link

moh-esmaeilzadeh commented Mar 2, 2022

I am modeling a hotel booking scenario. I want to know does DA provides locking multiple keys dynamically?
for example like this:

StreamingLedger.State<String, Int> roomAvailabilities = tradeLedger.declareState("roomAvailabilities")
                .withKeyType(String.class)
                .withValueType(Int.class);

OutputTag<BookingResult> transactionResults = tradeLedger.usingStream(bookings, "bookings")
                .apply(new CheckAndUpdateAvailabilityHandler())
                .on(roomAvailabilities, Booking::getRoomIds, "rooms", READ_WRITE)
                .output();

and then access to it inside the CheckAndUpdateAvailabilityHandler like this:

static final class CheckAndUpdateAvailabilityHandler extends TransactionProcessFunction<Booking, BookingResult> {

        @ProcessTransaction
        public void Booking(
                final Booking book,
                final Context<Booking> ctx,
                final @State("rooms") StateAccess<Int> rooms) {
//and In here I can access to rooms and check availability of all of them
        }
    }

I also wonder if Data Artisan is available for scala language?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant