doProductCheck calls f if there as not been a prior successful call to doProductCheck, returning nil otherwise.
(f func() error)
| 603 | // doProductCheck calls f if there as not been a prior successful call to doProductCheck, |
| 604 | // returning nil otherwise. |
| 605 | func (c *BaseClient) doProductCheck(f func() error) error { |
| 606 | c.productCheckMu.RLock() |
| 607 | productCheckSuccess := c.productCheckSuccess |
| 608 | c.productCheckMu.RUnlock() |
| 609 | |
| 610 | if productCheckSuccess { |
| 611 | return nil |
| 612 | } |
| 613 | |
| 614 | c.productCheckMu.Lock() |
| 615 | defer c.productCheckMu.Unlock() |
| 616 | |
| 617 | if c.productCheckSuccess { |
| 618 | return nil |
| 619 | } |
| 620 | |
| 621 | if err := f(); err != nil { |
| 622 | return err |
| 623 | } |
| 624 | |
| 625 | c.productCheckSuccess = true |
| 626 | |
| 627 | return nil |
| 628 | } |
| 629 | |
| 630 | // genuineCheckHeader validates the presence of the X-Elastic-Product header |
| 631 | func genuineCheckHeader(header http.Header) error { |