-
Notifications
You must be signed in to change notification settings - Fork 11
/
models.go
38 lines (33 loc) · 1.39 KB
/
models.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
package provider
import (
"fmt"
"github.com/nats-io/nkeys"
)
type Topics struct {
LATTICE_LINK_GET string
LATTICE_LINK_DEL string
LATTICE_LINK_PUT string
LATTICE_SHUTDOWN string
LATTICE_HEALTH string
}
func LatticeTopics(h HostData, providerXkey nkeys.KeyPair) Topics {
// With secrets support in wasmCloud, links are delivered to the link put topic
// where the topic segment is the XKey provider public key. On wasmCloud host
// versions before secrets (<1.1.0), the topic segment is the provider key.
// We can determine the topic segment based on the presence of the host xkey
// public key and the provider xkey private key.
var providerLinkPutKey string
publicKey, err := providerXkey.PublicKey()
if h.HostXKeyPublicKey == "" || h.ProviderXKeyPrivateKey == "" || err != nil {
providerLinkPutKey = h.ProviderKey
} else {
providerLinkPutKey = publicKey
}
return Topics{
LATTICE_LINK_GET: fmt.Sprintf("wasmbus.rpc.%s.%s.linkdefs.get", h.LatticeRPCPrefix, h.ProviderKey),
LATTICE_LINK_DEL: fmt.Sprintf("wasmbus.rpc.%s.%s.linkdefs.del", h.LatticeRPCPrefix, h.ProviderKey),
LATTICE_LINK_PUT: fmt.Sprintf("wasmbus.rpc.%s.%s.linkdefs.put", h.LatticeRPCPrefix, providerLinkPutKey),
LATTICE_HEALTH: fmt.Sprintf("wasmbus.rpc.%s.%s.health", h.LatticeRPCPrefix, h.ProviderKey),
LATTICE_SHUTDOWN: fmt.Sprintf("wasmbus.rpc.%s.%s.default.shutdown", h.LatticeRPCPrefix, h.ProviderKey),
}
}