From 6329aace0db2b149c510a38b23f89b2f6098dcd9 Mon Sep 17 00:00:00 2001 From: Rin Arakaki Date: Mon, 10 Mar 2025 13:19:25 +0900 Subject: [PATCH] Use type transactionID --- agent.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent.go b/agent.go index 4f07dce..4d8e0ab 100644 --- a/agent.go +++ b/agent.go @@ -53,7 +53,7 @@ type Handler func(e Event) // Event is passed to Handler describing the transaction event. // Do not reuse outside Handler. type Event struct { - TransactionID [TransactionIDSize]byte + TransactionID transactionID Message *Message Error error } @@ -77,7 +77,7 @@ var ( // StopWithError removes transaction from list and calls handler with // provided error. Can return ErrTransactionNotExists and ErrAgentClosed. -func (a *Agent) StopWithError(id [TransactionIDSize]byte, err error) error { +func (a *Agent) StopWithError(id transactionID, err error) error { a.mux.Lock() if a.closed { a.mux.Unlock() @@ -101,7 +101,7 @@ func (a *Agent) StopWithError(id [TransactionIDSize]byte, err error) error { // Stop stops transaction by id with ErrTransactionStopped, blocking // until handler returns. -func (a *Agent) Stop(id [TransactionIDSize]byte) error { +func (a *Agent) Stop(id transactionID) error { return a.StopWithError(id, ErrTransactionStopped) } @@ -113,7 +113,7 @@ var ErrAgentClosed = errors.New("agent is closed") // Could return ErrAgentClosed, ErrTransactionExists. // // Agent handler is guaranteed to be eventually called. -func (a *Agent) Start(id [TransactionIDSize]byte, deadline time.Time) error { +func (a *Agent) Start(id transactionID, deadline time.Time) error { a.mux.Lock() defer a.mux.Unlock() if a.closed {