WithRandomID sets the lease ID to a random unique value
()
| 25 | |
| 26 | // WithRandomID sets the lease ID to a random unique value |
| 27 | func WithRandomID() Opt { |
| 28 | return func(l *Lease) error { |
| 29 | t := time.Now() |
| 30 | var b [3]byte |
| 31 | rand.Read(b[:]) |
| 32 | l.ID = fmt.Sprintf("%d-%s", t.Nanosecond(), base64.URLEncoding.EncodeToString(b[:])) |
| 33 | return nil |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // WithID sets the ID for the lease |
| 38 | func WithID(id string) Opt { |
searching dependent graphs…