/
identifiers.go
45 lines (38 loc) · 1.21 KB
/
identifiers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package statefun
import (
"fmt"
"github.com/sjwiesman/statefun-go/pkg/flink/statefun/internal/messages"
)
// A reference to a stateful function, consisting of a namespace and a name.
// A function's type is part of a function's Address and serves as integral
// part of an individual function's identity.
type FunctionType struct {
Namespace string
Type string
}
func (functionType *FunctionType) String() string {
return fmt.Sprintf("%s/%s", functionType.Namespace, functionType.Type)
}
// An Address is the unique identity of an individual {@link StatefulFunction}, containing
// of the function's FunctionType and an unique identifier within the type. The function's
// type denotes the class of function to invoke, while the unique identifier addresses the
// invocation to a specific function instance.
type Address struct {
FunctionType FunctionType
Id string
}
func (address *Address) String() string {
return fmt.Sprintf("%s/%s", address.FunctionType.String(), address.Id)
}
func fromInternal(address *messages.Address) *Address {
if address == nil {
return nil
}
return &Address{
FunctionType: FunctionType{
Namespace: address.Namespace,
Type: address.Type,
},
Id: address.Id,
}
}