这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Conversation

@akim-bow
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented Nov 30, 2023

README.md Outdated

`registerService` Gives an ability to register service without schema. Passed `service` could be

- Plain object. In this case all function properties will be registered as Air service functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest for consistency always write AIR uppercased https://fluence.dev/docs/build/glossary#air

README.md Outdated
`registerService` Gives an ability to register service without schema. Passed `service` could be

- Plain object. In this case all function properties will be registered as Air service functions.
- Class instance. All class functions without inherited ones will be registered as Air service functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not allow to call anything with this low level API including inherited class methods. I would also suggest to call them class methods instead of class functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with renaming.

The decision to forbid inherited props made to make an attempt for avoiding accidental calls of Object methods or Array methods or other prototype chain methods. It could be surprising and forces you to control every method in prototype chain to have robust code(Very hard or impossible if you use external lib).

Comment on lines 43 to 44
// TODO: load worker in parallel with avm and marine, test that it works
const worker = await getWorker("@fluencelabs/marine-worker", CDNUrl);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why not trying to do that right now? what's stoping you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all about the bug i discovered in threads.js package 2-3 months ago.
In short terms, bug arises when between worker init and it's actual usage passes too much time.
That's why i want to accomplish this important optimization in an another task later. Because it could involve editing @fluencelabs/threads.js package.

Comment on lines 160 to 161
const marineDeps = await parallelLoadStrategy("/");
const marine = new MarineBackgroundRunner(...marineDeps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parallelLoadStrategy sound a bit generic and I don't know if it is a strategy. You actually load stuff with this function. maybe loadMarineDependencies I don't know. Also these two steps seem to be always together. Do you expect to ever need to call this function without passing args to MarineBackgroundRunner? In any case I would create a helper function e.g. initMarine or something that does both of these steps and returns marine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's more about inversion of control. In other words, i'd like to make MarineBackgroundRunner unaware of how these deps are loaded. Thats why i want to explicitly do these on a separate lines. For example in unit tests these deps could be mocked or substituted somehow.

I cannot come up with more strategies for this case. So yeah, looks like it's better to avoid strategies and just use a helper function as you suggested.

}
}

describe("User API methods", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think, maybe we need a simple test here that checks that inherited methods work if you use high level api? Do you have this test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you want to not allow this for high level api as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Actually yes, i want to allow calling inherited methods in high level api. Because if not, it would be surprising for user that he passes ts validation and fails at runtime because his methods are inherited.

Comment on lines +35 to +36
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const prototype = Object.getPrototypeOf(service) as ServiceImpl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move this directly inside if statement because it seems to be needed only if isClassInstance

@fluencebot fluencebot mentioned this pull request Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

e2e Run e2e workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants