Initial Bus implementation
This commit is contained in:
17
object.go
17
object.go
@@ -1,18 +1,17 @@
|
||||
package main
|
||||
|
||||
import "encoding/hex"
|
||||
import "fmt"
|
||||
|
||||
type Object interface {
|
||||
GetType() string
|
||||
GetId() string
|
||||
GetType() string
|
||||
GetId() string
|
||||
}
|
||||
|
||||
func ObjectSafeId(obj Object) string {
|
||||
return hex.EncodeToString([]byte(obj.GetId()))
|
||||
}
|
||||
|
||||
func ObjectKey(obj Object) string {
|
||||
return fmt.Sprintf(
|
||||
"%d:%s:%d:%s",
|
||||
len(obj.GetType()),
|
||||
obj.GetType(),
|
||||
len(obj.GetId()),
|
||||
obj.GetId(),
|
||||
)
|
||||
return fmt.Sprintf("%s:%s", obj.GetType(), ObjectSafeId(obj))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user