func (c *tokenCollector) Collect(tokenName, accessToken string) error {
	logger := c.log.WithFields(logrus.Fields{
		"module":   "tokenCollector",
		"function": "Collect",
	})

	logger.Debug("acquiring tokensLock")
	c.tokensLock.Lock()
	logger.Debug("acquired tokensLock")
	defer func() {
		logger.Debug("releasing tokensLock")
		c.tokensLock.Unlock()
	}()

	tokenNameExists := c.tokenNameExists(tokenName)
	logger.WithFields(logrus.Fields{
		"tokenName":       tokenName,
		"accessToken":     accessToken,
		"tokenNameExists": tokenNameExists,
	}).Debug("Collecting ...")
	if !tokenNameExists {
		return errors.New("invalid token name: " + tokenName)
	}

	c.addAccessToken(tokenName, accessToken)
	logger.WithFields(logrus.Fields{
		"collected": c.collected,
		"total":     len(c.consentTable),
	}).Debug("Collected")
	if c.isDone() {
		tokenNames := []string{}
		for _, item := range c.consentTable {
			tokenNames = append(tokenNames, item.TokenName)
		}

		acquiredAllAccessTokens := events.NewAcquiredAllAccessTokens(tokenNames)
		c.events.AddAcquiredAllAccessTokens(acquiredAllAccessTokens)

		if c.doneFunc != nil {
			logger.Debug("Calling doneFunc ...")
			c.doneFunc()
		}
	}

	return nil
}
// Collect receives an accesstoken to match a named token for which we have a consentid
Collect receives an accesstoken to match a named token for which we have a consentid
// Collect receives an accesstoken to match a named token for which we have a consentid
func (c *tokenCollector) Collect(tokenName, accessToken string) error {
	logger := c.log.WithFields(logrus.Fields{
		"module":   "tokenCollector",
		"function": "Collect",
	})
	logger.Debug("acquiring tokensLock")
	c.tokensLock.Lock()
	logger.Debug("acquired tokensLock")
	defer func() {
		logger.Debug("releasing tokensLock")
		c.tokensLock.Unlock()
	}()
	tokenNameExists := c.tokenNameExists(tokenName)
	logger.WithFields(logrus.Fields{
		"tokenName":       tokenName,
		"accessToken":     accessToken,
		"tokenNameExists": tokenNameExists,
	}).Debug("Collecting ...")
	if !tokenNameExists {
		return errors.New("invalid token name: " + tokenName)
	}
	c.addAccessToken(tokenName, accessToken)
	logger.WithFields(logrus.Fields{
		"collected": c.collected,
		"total":     len(c.consentTable),
	}).Debug("Collected")
	if c.isDone() {
		tokenNames := []string{}
		for _, item := range c.consentTable {
			tokenNames = append(tokenNames, item.TokenName)
		}
		acquiredAllAccessTokens := events.NewAcquiredAllAccessTokens(tokenNames)
		c.events.AddAcquiredAllAccessTokens(acquiredAllAccessTokens)
		if c.doneFunc != nil {
			logger.Debug("Calling doneFunc ...")
			c.doneFunc()
		}
	}
	return nil
}
func ( c * tokenCollector ) Collect ( tokenName , accessToken string ) error { logger := c . log . WithFields ( logrus . Fields { " " : " " , " " : " " , } ) logger . Debug ( " " ) c . tokensLock . Lock ( ) logger . Debug ( " " ) defer func ( ) { logger . Debug ( " " ) c . tokensLock . Unlock ( ) } ( ) tokenNameExists := c . tokenNameExists ( tokenName ) logger . WithFields ( logrus . Fields { " " : tokenName , " " : accessToken , " " : tokenNameExists , } ) . Debug ( " " ) if ! tokenNameExists { return errors . New ( " " + tokenName ) } c . addAccessToken ( tokenName , accessToken ) logger . WithFields ( logrus . Fields { " " : c . collected , " " : len ( c . consentTable ) , } ) . Debug ( " " ) if c . isDone ( ) { tokenNames := [ ] string { } for _ , item := range c . consentTable { tokenNames = append ( tokenNames , item . TokenName ) } acquiredAllAccessTokens := events . NewAcquiredAllAccessTokens ( tokenNames ) c . events . AddAcquiredAllAccessTokens ( acquiredAllAccessTokens ) if c . doneFunc != nil { logger . Debug ( " " ) c . doneFunc ( ) } } return nil }
Collect receives an accesstoken to match a named token for which we have a consentid
Collect receives an accesstoken to match a named token for which we have a consentid