Created
November 9, 2022 11:17
-
-
Save hotafrika/dcbae89bf74a0ad9bd4536cffd4e7178 to your computer and use it in GitHub Desktop.
medium / singleflight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type NodeStat struct { | |
// NodeData []byte // omit it for this example | |
NodeID string | |
Timestamp time.Time | |
} | |
type App struct {} | |
func (a *App) GetNodeStatSync(nodeID string) (*NodeStat, error) { | |
collectedAt := time.Now() | |
// Add some time for workload emulation. | |
time.Sleep(10 * time.Second) | |
return &NodeStat{ | |
NodeID: nodeID, | |
Timestamp: collectedAt, | |
}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment