hazelcast-nodejs-client icon indicating copy to clipboard operation
hazelcast-nodejs-client copied to clipboard

generate Codecs with protocol repo and implement Topic [API-1521]

Open fatihozer0 opened this issue 3 years ago • 1 comments

There are many problems. All in the comments of the files. They will be deleted. Lint problems will be fixed too.

fatihozer0 avatar Sep 14 '22 09:09 fatihozer0

Codecov Report

Merging #1367 (28edf28) into master (18c7f58) will increase coverage by 0.34%. The diff coverage is 95.50%.

@@            Coverage Diff             @@
##           master    #1367      +/-   ##
==========================================
+ Coverage   93.11%   93.46%   +0.34%     
==========================================
  Files         465      471       +6     
  Lines       16430    16789     +359     
  Branches     1337     1356      +19     
==========================================
+ Hits        15298    15691     +393     
+ Misses        830      801      -29     
+ Partials      302      297       -5     
Impacted Files Coverage Δ
src/config/Config.ts 98.24% <ø> (ø)
src/config/SSLConfig.ts 100.00% <ø> (ø)
src/discovery/HazelcastCloudDiscovery.ts 86.36% <ø> (ø)
src/proxy/MessageListener.ts 100.00% <ø> (ø)
src/serialization/compact/Schema.ts 78.57% <ø> (ø)
...rialization/generic_record/CompactGenericRecord.ts 97.26% <ø> (+1.31%) :arrow_up:
src/serialization/generic_record/GenericRecords.ts 100.00% <ø> (ø)
src/codec/SqlExecuteCodec.ts 95.74% <66.66%> (-4.26%) :arrow_down:
src/invocation/InvocationService.ts 94.87% <84.21%> (+0.36%) :arrow_up:
src/network/Connection.ts 95.72% <86.66%> (+0.61%) :arrow_up:
... and 124 more

... and 5 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Sep 14 '22 09:09 codecov[bot]

I get this error:

RangeError: There is no suitable deserializer for data with type 12582913
    at SerializationServiceV1.toObject (/Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/serialization/SerializationService.js:103:19)
    at TopicProxy.toObject (/Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/proxy/BaseProxy.js:135:42)
    at /Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/proxy/topic/TopicProxy.js:40:42
    at Function.handle (/Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/codec/TopicAddMessageListenerCodec.js:60:13)
    at Invocation.handler [as eventHandler] (/Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/proxy/topic/TopicProxy.js:37:73)
    at InvocationService.callEventHandlerWithMessage (/Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/invocation/InvocationService.js:337:24)
    at /Users/fatihozer/Desktop/hazelcast/client/hazelcast-nodejs-client/lib/invocation/InvocationService.js:369:26
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

while trying to run this code . Is not this weird?

fatihozer0 avatar Dec 29 '22 08:12 fatihozer0

it seems totally weird. Let me try the code sample. I will comment about it

srknzl avatar Dec 30 '22 13:12 srknzl

diff --git a/src/proxy/topic/TopicProxy.ts b/src/proxy/topic/TopicProxy.ts
index d6cfc637..5a2224f0 100644
--- a/src/proxy/topic/TopicProxy.ts
+++ b/src/proxy/topic/TopicProxy.ts
@@ -64,19 +64,16 @@ export class TopicProxy<E> extends PartitionSpecificProxy implements ITopic<E> {
         assertNotNull(message);
 
         const messageData = this.toData(message);
-        const request = TopicPublishCodec.encodeRequest(this.name, messageData);
         const partitionId = this.partitionService.getPartitionId(messageData);
-        return this.encodeInvokeOnPartition(TopicPublishCodec, partitionId, () => {
-        }, request);
+        return this.encodeInvokeOnPartition(TopicPublishCodec, partitionId, () => {}, messageData);
     }
 
     publishAll(messages: any[]): Promise<void> {
         assertNotNull(messages);
         const messageDataList = this.toData(messages);
-        const request = TopicPublishCodec.encodeRequest(this.name, messageDataList);
         const partitionId = this.partitionService.getPartitionId(messageDataList);
         return this.encodeInvokeOnPartition(TopicPublishCodec, partitionId, () => {
-        }, request);
+        }, messageDataList);
     }
 
     addListener(listener: MessageListener<E>): Promise<string> {

srknzl avatar Dec 30 '22 16:12 srknzl

@fatihozer0 If you apply this diff, it will be fixed. There is an error in your encodeInvokeOnPartition method usage.

srknzl avatar Dec 30 '22 16:12 srknzl

@fatihozer0 If you apply this diff, it will be fixed. There is an error in your encodeInvokeOnPartition method usage.

Now it looks like the sample is working. If everything looks good I am going to fix minor problems, lints etc. @srknzl

fatihozer0 avatar Jan 26 '23 16:01 fatihozer0

@fatihozer0 Checking the PR. I will let you know how the PR looks like right now.

srknzl avatar Jan 30 '23 20:01 srknzl

@fatihozer0 I reviewed your PR but the most important thing is missing: tests

srknzl avatar Jan 30 '23 21:01 srknzl

@fatihozer0 I reviewed your PR but the most important thing is missing: tests

Added but last 2 tests are timed out. Where do you think the problem is?

fatihozer0 avatar Feb 04 '23 19:02 fatihozer0

Added but last 2 tests are timed out. Where do you think the problem is?

No idea, did you try debugging? I will check this PR again when you resolve all my comments.

srknzl avatar Feb 08 '23 09:02 srknzl

@fatihozer0 Can you update https://github.com/srknzl/hazelcast-nodejs-client/blob/9ad6b4847b3b7edce3357a6dfbdfb027c0c667c0/src/proxy/MessageListener.ts#L21. You should say ITopic not reliable topic

srknzl avatar Feb 13 '23 15:02 srknzl

@fatihozer0 Same for https://github.com/srknzl/hazelcast-nodejs-client/blob/9ad6b4847b3b7edce3357a6dfbdfb027c0c667c0/src/proxy/MessageListener.ts#L26

srknzl avatar Feb 13 '23 15:02 srknzl

General idea about how many tests you should add:

You added publishAll to both proxies. You added addListener and removeListener to all proxies as well. Basic tests about their basic functionality would be good.

Also, we disallow addMessageListener and removeMessageListener methods from TopicProxy. You need to write a test about the exception throw behavior when these methods are called from TopicProxy.

Also can you add the tests you mention in the TDD ?

image

srknzl avatar Feb 13 '23 16:02 srknzl