wip: migrate to mono-repo. SPN has already been moved to spn/
This commit is contained in:
27
spn/terminal/fmt.go
Normal file
27
spn/terminal/fmt.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package terminal
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CustomTerminalIDFormatting defines an interface for terminal to define their custom ID format.
|
||||
type CustomTerminalIDFormatting interface {
|
||||
CustomIDFormat() string
|
||||
}
|
||||
|
||||
// FmtID formats the terminal ID together with the parent's ID.
|
||||
func (t *TerminalBase) FmtID() string {
|
||||
if t.ext != nil {
|
||||
if customFormatting, ok := t.ext.(CustomTerminalIDFormatting); ok {
|
||||
return customFormatting.CustomIDFormat()
|
||||
}
|
||||
}
|
||||
|
||||
return fmtTerminalID(t.parentID, t.id)
|
||||
}
|
||||
|
||||
func fmtTerminalID(craneID string, terminalID uint32) string {
|
||||
return fmt.Sprintf("%s#%d", craneID, terminalID)
|
||||
}
|
||||
|
||||
func fmtOperationID(craneID string, terminalID, operationID uint32) string {
|
||||
return fmt.Sprintf("%s#%d>%d", craneID, terminalID, operationID)
|
||||
}
|
||||
Reference in New Issue
Block a user