MySQL Auction?

29 views
Skip to first unread message

Rick Mann

unread,
Oct 19, 2016, 10:40:00 PM10/19/16
to Baratine
Is there a version of Auction using MySQL?

One of the things that's hard when learning Baratine or developing a new app is not having insight into the persisted data, nor being able to hand-craft some data for use by the emerging codebase, before all the code to create data is in place. Using MySQL instead of Baratine's default persistence might be helpful in that regard, but aside from the simple jdbc example in the docs, I'm not at all sure how to integrate it into the thing I've built based on Auction.

Thanks,

--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 19, 2016, 10:58:14 PM10/19/16
to Rick Mann, Baratine
We don't have a Vault implementation backed up by JDBC, but there is a
JDBC service that could be used to do this
http://doc.baratine.io/javadoc/v1.0/ .

Though a reactive application should try to stay reactive. Introducing
blocking layer weakens the architecture.

The initial data should really be injected with Unit test's setup method.

Alex
> --
> You received this message because you are subscribed to the Google Groups "Baratine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to baratine-io...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Rick Mann

unread,
Oct 19, 2016, 11:29:28 PM10/19/16
to Baratine, Alex Rojkov
Well, there's no avoiding blocking, right? I mean, just computing the Bcrypt hash is lengthy, and Baratine's entire design philosophy is to do these things asynchronously in background threads so the main thread handling responses doesn't block, right? So why does it matter that JDBC is blocking?
--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 20, 2016, 6:46:49 PM10/20/16
to Rick Mann, Baratine
Just remember that there is one thread per service normally, so if
persistence is implemented as a proxy to blocking service (JDBC /
Hibernate) scaling such service is achieved with @Workers. @Workers
will use a Pool of Service instances each running in it's own thread
context thus parallelizing the work.

Alex

Rick Mann

unread,
Oct 20, 2016, 7:15:01 PM10/20/16
to Alex Rojkov, Baratine
Ah, okay. That makes sense for the Baratine model, but hits up against another area where I don't understand Baratine as well as I would like.

When I first learned about Baratine, a "Service" was a thing that acted both like an object representing a row in a table, and a thing that responded to web requests. In the later examples, a Service seems to be something that can also live independent of the web (e.g. under the "service://" URL scheme).

Really, I just have a lot of confusion about Sessions, Vaults, and Users (to work with a concrete example). In my Auction-derived app, User is a Service. But to me, User should be a row in a table (conceptually; it doesn't have to actually be a SQL DB). Should I rename my User class to UserService (and User.Data to User)?

I tried to make an object graph of Auction:

https://cl.ly/0D2f2W0I0I0k

It attempts to show the inheritance hierarchy (thick-border boxes are classes, everything else is an interface). Generic typing is shown with a long-dash line. Dot-dash shows has-a relationship. Double arrows mean multiple instances. Short-dashed lines show where main() include()s classes.

One of the things that throws me in this is that there is a Vault<User> for each user. Why is there not just a single Vault for all Users?

No, wait, that's not quite right. My User is an @Asset and an @Api, not a @Service. My User interface has create() and get() methods (that unfortunately know something about the web interface), and the derived UserImpl has fields for each individual user. Augh, this is so confusing to me.

Sorry. I'm lost and about to give up and go back to Spring for this project.
--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 20, 2016, 8:29:06 PM10/20/16
to Rick Mann, Baratine
@Asset marked interface or class represents a row in a database, it
should only deal with its own data.

@Asset
interface User (Impl) is a user row and should only deal with its own
data. Method create() of the User should be scoped to deal with this
user's data only.

Vault<User...> is a collection of Users. It might have data pertaining
to all users. e.g. it might store a collection of account names being
registered.

User doesn't have to know about Web. In Auction object for Web e.g.
WebUser belong to @Session, which is a web facing service (session
scoped).

Alex

Alex Rojkov

unread,
Oct 20, 2016, 8:37:25 PM10/20/16
to Rick Mann, Baratine
Also, speaking of Spring / Hibernate, the thinking can go along these
line: @Asset is an @Enitty. Vault is Spring's Data Repository. I think
it helps to draw the parallels.

Your feedback is valuable, thank you.

Alex

Rick Mann

unread,
Oct 20, 2016, 8:49:51 PM10/20/16
to Alex Rojkov, Baratine
Okay, I'm good with that; I realize I do only have one Vault for all my users. It's a bit weird, though, that I have to make a UserAbstractVault that is generic, and then specify it with a User type (i.e. UserAbstractVault<User>). And on top of that, I have to make an interface "UserVault extends UserAbstractVault<UserImpl>".

I can't reuse UserAbstractVault<> for any other table types, and the Impl interface is empty.

That's four classes (and files) for each entity type in my application. Can that be simplified? Do I lose anything if I instead define my Vault and User like this? Is this even allowed?

https://gist.github.com/JetForMe/ef7a3510620b792d155aa0cf747c442a?ts=4
--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 20, 2016, 9:14:13 PM10/20/16
to Rick Mann, Baratine
Yes to the gist. The hierarchy is useful the you need to replace
UserImpl with UserMock for testing, while still using User interface
for all the calls. Your gist is the simplest case and it should work
fine.

Alex

Rick Mann

unread,
Oct 20, 2016, 9:30:19 PM10/20/16
to Alex Rojkov, Baratine
Right, that's a pretty important loss, I think. Do I need both UserVault and User to be mock-able, or just the Vault? Or can I still do automated unit testing without the mock?

Can you point me at an example that does testing with UserMock?

Thanks!

Alex Rojkov

unread,
Oct 20, 2016, 10:23:26 PM10/20/16
to Rick Mann, Baratine
Yep. In Auction example I am showing how to use mock in the test
below. The UserMockVault is needed as well as the UserMock. However,
the UserMockVault is only used to specify concrete class for User
interface.

https://github.com/baratine/auction/blob/master/src/test/java/examples/auction/AuctionSettleRejectUserTest.java

Alex

Rick Mann

unread,
Oct 21, 2016, 2:36:02 AM10/21/16
to Alex Rojkov, Baratine
Still struggling with the continuation calls. How would I modify this code to use RequestWeb instead of Result<UserPublic>?

https://github.com/JetForMe/hoa/blob/master/src/main/java/com/latencyzero/hoa/AbstractHOASession.java?ts=4#L40

Thanks!
--
Rick Mann
rm...@latencyzero.com


Reply all
Reply to author
Forward
0 new messages