Skip to content

Commit

Permalink
Migrate to new Runtime APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Nov 13, 2024
1 parent 3ec3a93 commit b9773d8
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.ballerina.testobserve.listenerendpoint;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.async.StrandMetadata;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.ObjectType;
Expand Down Expand Up @@ -243,22 +243,12 @@ protected void channelRead0(ChannelHandlerContext ctx, Object o) {

Map<String, Object> properties = new HashMap<>();
properties.put(ObservabilityConstants.KEY_OBSERVER_CONTEXT, observerContext);

StrandMetadata strandMetadata = new StrandMetadata(TEST_OBSERVE_PACKAGE.getOrg(),
TEST_OBSERVE_PACKAGE.getName(), TEST_OBSERVE_PACKAGE.getMajorVersion(),
resourceFunctionName);
Utils.logInfo("Dispatching resource " + resourcePath);
ObjectType objectType = (ObjectType) serviceObject.getOriginalType();
Object result;

try {
if (objectType.isIsolated() && objectType.isIsolated(resourceFunctionName)) {
result = env.getRuntime().startIsolatedWorker(serviceObject, resourceFunctionName, null,
strandMetadata, properties, args).get();
} else {
result = env.getRuntime().startNonIsolatedWorker(serviceObject, resourceFunctionName, null,
strandMetadata, properties, args).get();
}
boolean isConcurrentSafe = objectType.isIsolated() && objectType.isIsolated(resourceFunctionName);
StrandMetadata metadata = new StrandMetadata(isConcurrentSafe, properties);
Object result = env.getRuntime().callMethod(serviceObject, resourceFunctionName, metadata, args);
handleResult(ctx, result, resourcePath);
} catch (BError error) {
handleError(ctx, error, resourcePath);
Expand Down

0 comments on commit b9773d8

Please sign in to comment.