Coder Social home page Coder Social logo

Comments (3)

chongkai avatar chongkai commented on July 18, 2024

Mentioned in https://pkg.go.dev/go.temporal.io/[email protected]/activity,

Currently cancellation is delivered only to Activities that call RecordHeartbeat.

Is this the cause?

from samples-go.

dnr avatar dnr commented on July 18, 2024

The sample code is calling RecordHeartbeat, though, so that's not quite the problem. What appears to be happening is that cancellation is only delivered when a heartbeat is actually sent, and the sdk does batching of heartbeats internally, so that a call to activity.RecordHeartbeat doesn't necessarily send a heartbeat. The batching is based on the value of HeartbeatTimeout.

You can see this by changing the duration of f1 to 60 seconds instead of 5 seconds: the activity will be cancelled after around 8 seconds (with HeartbeatTimeout set to 10 seconds). If you increase HeartbeatTimeout it'll take longer, and if you decrease it, the cancellation will be delivered sooner. You can see the logic here: https://github.com/temporalio/sdk-go/blob/1ec44328977e7bb896d2d405a8f1334120df282a/internal/internal_task_handlers.go#L1628

So this doesn't seem like a bug, though there's probably room to improve the documentation.

from samples-go.

chongkai avatar chongkai commented on July 18, 2024

Thanks @dnr for your clarification! However, these internals seem a bit obscure to new comers. I submitted a PR (#111) in hopes that it could help others better understand the sample. If it doesn't fit the purpose of the sample, please let me know.

from samples-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.