mirror of
https://github.com/fosrl/newt.git
synced 2026-04-04 00:46:40 +00:00
Add provisioning blueprint file
This commit is contained in:
@@ -53,6 +53,7 @@ type Client struct {
|
||||
processingMessage bool // Flag to track if a message is currently being processed
|
||||
processingMux sync.RWMutex // Protects processingMessage
|
||||
processingWg sync.WaitGroup // WaitGroup to wait for message processing to complete
|
||||
justProvisioned bool // Set to true when provisionIfNeeded exchanges a key for permanent credentials
|
||||
}
|
||||
|
||||
type ClientOption func(*Client)
|
||||
@@ -102,6 +103,16 @@ func (c *Client) OnTokenUpdate(callback func(token string)) {
|
||||
c.onTokenUpdate = callback
|
||||
}
|
||||
|
||||
// WasJustProvisioned reports whether the client exchanged a provisioning key
|
||||
// for permanent credentials during the most recent connection attempt. It
|
||||
// consumes the flag – subsequent calls return false until provisioning occurs
|
||||
// again (which, in practice, never happens once credentials are persisted).
|
||||
func (c *Client) WasJustProvisioned() bool {
|
||||
v := c.justProvisioned
|
||||
c.justProvisioned = false
|
||||
return v
|
||||
}
|
||||
|
||||
func (c *Client) metricsContext() context.Context {
|
||||
c.metricsCtxMu.RLock()
|
||||
defer c.metricsCtxMu.RUnlock()
|
||||
|
||||
@@ -264,6 +264,7 @@ func (c *Client) provisionIfNeeded() error {
|
||||
c.config.ProvisioningKey = ""
|
||||
c.config.Name = ""
|
||||
c.configNeedsSave = true
|
||||
c.justProvisioned = true
|
||||
|
||||
// Save immediately so that if the subsequent connection attempt fails the
|
||||
// provisioning key is already gone from disk and the next retry uses the
|
||||
|
||||
Reference in New Issue
Block a user