ThreadService
import { ThreadService } from "@skipcheck/tm1-client"; Server threads: what the server is doing right now (/Threads), and cancelling
an operation, which is how to stop a running process: cancelling a client's request
doesn't.
See what the server is busy with:
// What the server is doing now: every thread that isn't idle
const notIdle = ODataQuery.none()
.select(Thread.Fields.ID, Thread.Fields.Name, Thread.Fields.Function, Thread.Fields.ElapsedTime)
.filter(Thread.Fields.State.ne("Idle"));
const threads = await tm1.threads.list(notIdle).toArray();
return threads.map((thread) => `${thread.Name}: ${thread.Function} for ${thread.ElapsedTime}`);
Stop a running process by cancelling its thread, found by its request:
// A process run through REST shows as its request, not by its name
const running = ODataQuery.none().select(Thread.Fields.ID).filter(Filter.contains(Thread.Fields.Function, "Processes('Sales.Load')/tm1.ExecuteWithReturn"));
for await (const thread of tm1.threads.list(running)) await tm1.threads.cancel(thread.ID!);
Members
ThreadService constructor | A service sending its requests through session. |
list | GET Threads, streamed. |
get | The thread, or a Tm1NotFoundException if it's gone. |
session | The thread's session. |
cancel | Asks the thread to stop what it's doing, such as a running process. |
ThreadService
constructorconstructor(session: Tm1Session)A service sending its requests through session.
list
list(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Thread>GET Threads, streamed. A process run through REST shows as its request: Function is POST /api/v1/Processes('name')/tm1.ExecuteWithReturn, and TM1 (11.8) leaves ObjectName empty.
TM1 REST EntitySet Threads
get
get(id: number, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Thread>GET Threads(id): the thread, or a Tm1NotFoundException if it's gone.
TM1 REST EntitySet Threads
session
session(id: number, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Session>GET Threads(id)/Session: the thread's session.
TM1 REST Navigation Thread/Session
cancel
cancel(id: number, options?: Tm1CallOptions): Promise<void>tm1.CancelOperation: asks the thread to stop what it's doing, such as a running process. TM1 (11.8) then fails the process's ExecuteWithReturn request with 500, TM1UserException: Cancel (code 174), rather than reporting it Aborted. Needs schema 10.2.2.1. Resolves when the request is made; the thread stops soon after.
TM1 REST Action Thread/CancelOperation