Skip to content

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

@moh-esmaeilzadeh

Description

@moh-esmaeilzadeh

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions