func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (storage blobserver.Storage, err os.Error) { sto := &replicaStorage{ SimpleBlobHubPartitionMap: &blobserver.SimpleBlobHubPartitionMap{}, } sto.replicaPrefixes = config.RequiredList("backends") nReplicas := len(sto.replicaPrefixes) sto.minWritesForSuccess = config.OptionalInt("minWritesForSuccess", nReplicas) if err := config.Validate(); err != nil { return nil, err } if nReplicas == 0 { return nil, os.NewError("replica: need at least one replica") } if sto.minWritesForSuccess == 0 { sto.minWritesForSuccess = nReplicas } sto.replicas = make([]blobserver.Storage, nReplicas) for i, prefix := range sto.replicaPrefixes { replicaSto, err := ld.GetStorage(prefix) if err != nil { return nil, err } sto.replicas[i] = replicaSto } return sto, nil }
func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (storage blobserver.Storage, err os.Error) { sto := &shardStorage{ SimpleBlobHubPartitionMap: &blobserver.SimpleBlobHubPartitionMap{}, } sto.shardPrefixes = config.RequiredList("backends") if err := config.Validate(); err != nil { return nil, err } if len(sto.shardPrefixes) == 0 { return nil, os.NewError("shard: need at least one shard") } sto.shards = make([]blobserver.Storage, len(sto.shardPrefixes)) for i, prefix := range sto.shardPrefixes { shardSto, err := ld.GetStorage(prefix) if err != nil { return nil, err } sto.shards[i] = shardSto } return sto, nil }