@function ImmutableCoreService

create new service

@param {object} args

@returns {ImmutableCoreService}

@throws {Error}
519601
function ImmutableCoreService (args) {
    // require valid args
    this.assert(typeof args === 'object', 'args must be object')
    // require name for service
    this.assert(typeof args.name === 'string', 'name required')
    // set service name
    this.name = args.name
    // build module name from name
    this.moduleName = `${this.name}Service`
    // instantiate module - will throw error if name already defined
    this.module = ImmutableCore.module(this.moduleName, {})
    // require initialize function
    this.assert(typeof args.initialize === 'function', 'initialize function required')
    // create initialize method
    this.module.method('initialize', args.initialize)
    // make sure service not already registered
    this.assert(!this.hasService(this.name), 'service ${this.name} already registered')
    // add service to global register
    this.getServices()[this.name] = this
    // add any additional methods
    _.each(args.methods, (method, methodName) => {
        // add immutable method to service
        this[methodName] = this.module.method(methodName, method)
    })
    // if reinitialize interval is set then validate
    if (defined(args.reinitializeInterval)) {
        // validate
        this.assert(!Number.isNaN(parseInt(args.reinitializeInterval)), 'reinitializeInterval must be integer')
        // set value
        this.reinitializeInterval = parseInt(args.reinitializeInterval)
    }
    // default to 0 - do not reinitialize
    else {
        this.reinitializeInterval = 0
    }
}
819380
function(service) {
      return {
        compose: _.uniq(app.composeCore),
        project: app.name,
        opts: {
          app: app,
          services: [service]
        }
      };
    }
100599
function spawnService(serviceName, type, initWait) {
    // Type can be either service or coreService
    // When coreService, a service from the core-service folder will be spawned
    type = type || 'service';

    // If init wait is set, we will wait for the INITDONE signal before resolving the promise
    initWait = initWait || false;

    // Load the service and return a promise
    return new unicorn.promise(function(resolve, reject){

        if(typeof(serviceName) == 'undefined') reject({msg:'No service name'});

        try {
            // We must fix the hardcoded config path.. or maybe not
            // Maybe change the name of the config to unicorn config and make this default
            var service = Spawn('node', [unicorn.path + '/spawn.js', config.unicornPath + '/config.json', serviceName, type]);

            // Print errors on the console when errors comes in
            service.stderr.on('data', function (data) {
                // Replace newlines, because data is a buffer and will print a newline for free
                console.log(data.toString().replace(/^\s+|\s+$/g, ''));
            });

            // Print info when a process exits
            service.on('close', function (code) {
                console.log('Child process: ' + serviceName + ' exited with code ' + code);
            });

            // Print info when a process exits
            service.on('exit', function (code) {
                console.log('Dirty child process: ' + serviceName + ' exit with code ' + code);
            });

            service.on('error', function (err) {
                console.log('Child process: ' + serviceName + ' error: ' + err);
            });

            // Switch the moment of the resolve, if initWait is enabled we must wait for a return signal
            if(initWait) {
                // Print data on the console when data comes in
                service.stdout.on('data', function (data) {
                    // Replace newlines, because data is a buffer and will print a newline for free
                    var procData = data.toString().replace(/^\s+|\s+$/g, '');

                    // See if we have a system message first, since we cannot use process.send we use std for messaging
                    if (procData == 'INITDONE') {
                        resolve({service: broker, name: broker.name, pid: broker.pid});
                    } else {
                        console.log(procData);
                    }
                });
            } else {
                // Print data on the console when data comes in
                service.stdout.on('data', function (data) {
                    // Replace newlines, because data is a buffer and will print a newline for free
                    console.log(data.toString().replace(/^\s+|\s+$/g, ''));
                });

                resolve({service:service, name:service.name, pid:service.pid});
            }
        } catch (err) {
            reject(err);
        }

    });
}
182002
function ImmutableCoreModel (args) {
    // store copy of original args
    this.args = _.cloneDeep(args)
    // initialize global data
    this.initGlobal(args)
    // create module and set options
    this.initModule(args)
    // initialize column spec for model
    this.initColumns(args)
    // initialize multi-column indexes
    this.initIndexes(args)
    // create and validate JSON schema
    this.initJsonSchema(args)
    // add create method to module
    this.initCreate(args)
    // add query method to module
    this.initQuery(args)
    // add associated actions
    this.initActions(args)
    // initialize any model views
    this.initViews(args)
    // initialize related models
    this.initRelations(args)
    // initialize access control
    this.initAccessControl(args)
    // create columnsId
    this.initIds()
}
280822
function handleArguments(args) {
  return new Promise(function(resolve, reject) {
    var requires = [];
    var promises = [];

    // check for Promises in args
    if (args && args instanceof Array) {
      args.some(function (arg, i) {
        if ((arg.value === null || typeof(arg.value) == 'undefined') && arg.optional) {
          return true;
        }

        if (arg.value && Array.isArray(arg.value) && arg.optional && arg.value.length == 0) {
          return true;
        }

        if (arg.type == 'string') {
          var s = '"' + arg.value.replace(/"/g, '\\\"') + '"';
          promises.push(Promise.resolve(s));
        } else if (arg.type == 'lambda') {
          promises.push(serializeLambda(arg.value));
        } else if (arg.type == 'lambdaArgs') {
          promises.push(new Promise(function(resolve, reject) {
            handleArrayArgument(arg.value).then(function (result) {
              resolve(result);
            }).catch(reject);
          }));
        } else if (arg.type == 'map') {
          promises.push(Promise.resolve(JSON.stringify(arg.value)));
        } else if (arg.type == 'promise') {
          promises.push(new Promise(function(resolve, reject) {
            arg.value.then(function(val) {
              if (typeof(val) == 'string') {
                if (isNaN(val)) {
                  // a string
                  var s = '"' + val.replace(/"/g, '\\\"') + '"';
                  resolve(s);
                } else {
                  resolve(parseFloat(val));
                }
              } else {
                resolve(val);
              }
            });
          }));
        } else if (arg.value.refIdP) {
          promises.push(arg.value.refIdP);
        } else if (arg.type == 'List') {
          promises.push(Promise.resolve(arg.value.toString()));
        } else if (arg.type == 'array') {
          // simple array argument
          promises.push(handleArrayArgument(arg.value));
        } else if (arg.type == '_eclairSerialize') {
          if (arg.value._eclairSerialize == 'staticProperty') {
            var val = arg.value.ref.name + '.' + arg.value.value;
            promises.push(Promise.resolve(val));
            requires.push({name: arg.value.ref.name, moduleLocation: arg.value.ref.moduleLocation});
          }
        } else if (Array.isArray(arg.value)) {
          // TODO: should we try to wrap the array if it isn't?
          promises.push(new Promise(function (resolve, reject) {
            handleArguments(arg.value).then(function (result) {
              if (result.requires.length > 0) {
                result.requires.forEach(function (r) {
                  requires.push(r)
                });
              }

              resolve('[' + result.args + ']');
            }).catch(reject);
          }));
        } else if (arg.type == '_eclairForceFloat') {
          var val = arg.value.value;
          if (val.toString().indexOf('.') === -1) {
            val = val.toFixed(1);
          }
          promises.push(Promise.resolve(val));
        } else if (arg.type == '_eclairLocal') {
          promises.push(Promise.resolve(arg.value._generateRemote().refIdP));
        } else if (arg.type == 'sparkclassref') {
          // we have a spark class reference, so return its name
          promises.push(Promise.resolve(arg.value.name));
          // add the class to the requires list
          requires.push({name: arg.value.name, moduleLocation: arg.value.moduleLocation});
        } else {
          promises.push(Promise.resolve(arg.value));
        }

        return false;
      });
    }

    Promise.all(promises).then(function(finalArgs) {
      resolve({args: finalArgs, requires: requires});
      //resolve(finalArgs);
    }).catch(function(e) {
      console.log(e);
      reject(e)
    });
  });
}
879028
function ImmutableCoreModelCache (args) {
    // require model
    this.assert(args.model && args.model.ImmutableCoreModel, 'model required')
    // require redis
    this.assert(args.redis, 'redis required')
    // store args
    this.model = args.model
    this.redis = args.redis
}
527129
def create_service(self, *args, **kwargs):
        
        return self._client.create_service(*args, scope=self.id, **kwargs)
266398
def _replace_service_arg(self, name, index, args):
        
        args[index] = self.get_instantiated_service(name)
1009099
function ImmutableCoreModelCacheQuerySelect (args) {
    // store args
    this.cache = args.cache
    this.query = args.query
    // init properties
    this.cached = null
    this.selectCacheKey = this.cacheKey()
}
36079
function initGlobal (args) {
    // do nothing if global data already defined
    if (global.__immutable_core_model__) {
        return
    }
    // create new global object
    var GLOBAL = global.__immutable_core_model__ = {
        // number of concurrent related queries to allow per query
        concurrency: 5,
        // default to use binary columns for ids
        defaultBinaryIds: true,
        // default character set
        defaultCharset: 'utf8',
        // default compression setting
        defaultCompression: true,
        // default elastic search client
        defaultElasticsearch: undefined,
        // default database engine
        defaultEngine: 'InnoDB',
        // default insert delayed option for myisam tables
        defaultInsertDelayed: false,
        // map of models indexed by name
        models: {},
    }
    // create validator as global object so that schemas will be shared
    // between all model classes
    GLOBAL.validator = new Ajv({
        allErrors: true,
        coerceTypes: 'array',
        removeAdditional: true,
        useDefaults: true,
        v5: true,
    })
}
530176
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new ServiceOptions();
			case 1:
				return new ServiceOptions(func_get_arg(0));
			case 2:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1));
			case 3:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
			case 7:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
			case 8:
				return new ServiceOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
			default:
				throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
		}
	}
830157
def make_service(self, my_args=None):
        
        LOGGER.debug("natsd.Driver.make_service")
        if my_args is None:
            raise exceptions.ArianeConfError('service factory arguments')
        if not self.configuration_OK or self.connection_args is None:
            raise exceptions.ArianeConfError('NATS connection arguments')
        service = Service.start(my_args, self.connection_args).proxy()
        self.services_registry.append(service)
        return service
629191
function (args) {
            this.type = "mixin";
            this.fn = function (service) {
                service.create = service[this.create];
                service.read = service[this.read];
                service.update = service[this.update];
                service.remove = service[this.remove];
            };
        }
646613
public T newInstance(Object... args) throws Throwable
    {
        Constructor<? extends T> constructor = ClassUtils.findBestTypedConstructor(klass, args);
        return ClassUtils.invoke(constructor, args);
    }
340521
function create(callback) {
  /* jslint validthis: true */
  for (var
    queue = this,
    args = [],
    info = {
      id: {},
      fn: callback,
      ar: args
    },
    i = 1; i < arguments.length; i++
  ) args[i - 1] = arguments[i];
  return infoId(queue, info) || (queue.push(info), info.id);
}
54502
@Override
    protected final T create(Object... args) {
        final K key = this.getKey(args);
        final T value = this.createInternal(key, args);
        this.objectCache.put(key, value);
        return value;
    }
521843
function ImmutableCoreModelLocal (args) {
    this.model = args.model
    this.session = args.session
    // add getter for select that will return a new select instance
    // whenever it is called
    Object.defineProperty(this, 'select', {
        get: () => {
            return new ImmutableCoreModelSelect({
                model: this.model,
                session: this.session,
            })
        }
    })
}