// TabletComplete validates and normalizes the tablet. If the shard name // contains a '-' it is going to try to infer the keyrange from it. func TabletComplete(tablet *pb.Tablet) error { shard, kr, err := ValidateShardName(tablet.Shard) if err != nil { return err } tablet.Shard = shard tablet.KeyRange = kr return nil }
// changeType is a single iteration of the update loop for ChangeType(). func changeType(tablet *topodatapb.Tablet, newType topodatapb.TabletType, health map[string]string) error { tablet.Type = newType if health != nil { if len(health) == 0 { tablet.HealthMap = nil } else { tablet.HealthMap = health } } return nil }
// changeType is a single iteration of the update loop for ChangeType(). func changeType(tablet *topodatapb.Tablet, newType topodatapb.TabletType, health map[string]string) error { if !topo.IsTrivialTypeChange(tablet.Type, newType) { return fmt.Errorf("cannot change tablet type %v -> %v for %v", tablet.Type, newType, tablet.Alias) } tablet.Type = newType if health != nil { if len(health) == 0 { tablet.HealthMap = nil } else { tablet.HealthMap = health } } return nil }