Topics returns a list of topics, as registered with SetTopicMetadata
()
| 69 | |
| 70 | // Topics returns a list of topics, as registered with SetTopicMetadata |
| 71 | func (c *Consumer) Topics() ([]string, error) { |
| 72 | c.l.Lock() |
| 73 | defer c.l.Unlock() |
| 74 | |
| 75 | if c.metadata == nil { |
| 76 | c.t.Errorf("Unexpected call to Topics. Initialize the mock's topic metadata with SetTopicMetadata.") |
| 77 | return nil, sarama.ErrOutOfBrokers |
| 78 | } |
| 79 | |
| 80 | var result []string |
| 81 | for topic := range c.metadata { |
| 82 | result = append(result, topic) |
| 83 | } |
| 84 | return result, nil |
| 85 | } |
| 86 | |
| 87 | // Partitions returns the list of parititons for the given topic, as registered with SetTopicMetadata |
| 88 | func (c *Consumer) Partitions(topic string) ([]int32, error) { |