// SaveServiceConfig saves service config into database. func SaveServiceConfig(serviceId string, conf apis.BinaryMarshaller) error { db := db.DatabaseInstance() data, _ := conf.Marshal() err := db.StoreData(cfgKey(serviceId), data) if err != nil { log.Error("Failed to save config: %s", err.Error()) return mpqerr.ServerError("Can not save service data: " + serviceId) } return nil }
func LoadServiceConfig(serviceId string, cfg apis.BinaryMarshaller) error { db := db.DatabaseInstance() data := db.GetData(cfgKey(serviceId)) if len(data) == 0 { return mpqerr.NotFoundRequest("No service settings found: " + serviceId) } if err := cfg.Unmarshal(data); err != nil { log.Error("Error in '%s' service settings: %s", serviceId, err.Error()) return mpqerr.ServerError("Service settings error: " + serviceId) } return nil }