ydb-platform/yoj-project

Move YdbRepository start behavior from YdbRepository constructor to separate method

lavrukov opened this issue · 3 comments

YdbRepository in the constructor establishes a connection to the database, because it is impossible to separate the stages of object initialization and start.

It seems that what is needed here is a factory object which will create a SessionManager and return a Repository

🤪 This is an unexpected change in YDB SDK v2, constructing a GrpcTransport immediately establishes a GRPC connection:

    public GrpcTransport build() {
        YdbTransportImpl impl = new YdbTransportImpl(this);
        try {
            impl.init();

We might just add a Guava Suppliers.memoize() for GrpcTransport and SessionManager in YdbRepository to make initialization lazy, as it was in repository-ydb-v1.

➡️ See PR with lazy initialization here:
#61

Fixed, the fix will appear in 2.2.11.