Initial Bus implementation

This commit is contained in:
Ian Gulliver
2022-03-15 16:27:52 +00:00
parent eb60a6aacf
commit 88c24f1a40
5 changed files with 120 additions and 69 deletions

View File

@@ -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))
}