コード例 #1
0
ファイル: debug.go プロジェクト: yacloud-io/cf-redis-broker
func getAllocatedInfo(repo *redis.RemoteRepository) (Allocated, error) {
	allocated := Allocated{}

	allocatedInstances, err := repo.AllInstances()
	if err != nil {
		return allocated, err
	}

	for _, instance := range allocatedInstances {
		bindingIDs, err := repo.BindingsForInstance(instance.ID)
		if err != nil {
			return allocated, err
		}

		c := Cluster{
			ID:    instance.ID,
			Hosts: []string{instance.Host},
		}

		for _, id := range bindingIDs {
			c.Bindings = append(c.Bindings, Binding{ID: id})
		}

		allocated.Clusters = append(allocated.Clusters, c)
	}

	allocated.Count = len(allocatedInstances)

	return allocated, nil
}
コード例 #2
0
			Context("when it cannot persist the state to the state file", func() {
				BeforeEach(func() {
					os.Remove(statefilePath)
					os.Mkdir(statefilePath, 0644)
				})

				AfterEach(func() {
					os.RemoveAll(statefilePath)
				})

				It("does not bind", func() {
					_, err := repo.Bind("foo", "bar-binding")
					Expect(err).To(HaveOccurred())

					bindings, err := repo.BindingsForInstance("foo")
					Expect(err).ToNot(HaveOccurred())

					Expect(len(bindings)).To(Equal(0))
				})
			})
		})

		Describe("#Unbind", func() {
			Context("when the binding exists", func() {
				BeforeEach(func() {
					_, err := repo.Bind("foo", "foo-binding")
					Expect(err).ToNot(HaveOccurred())
				})

				It("returns successfully", func() {