new Service(name, options)
Constructs a new service instance.
Parameters:
name |
string |
Service name |
options |
Object.<string, *> |
optional
Service options |
Throws:
| TypeError |
If arguments are invalid |
Extends
Members
-
Comment text, if any.
-
Defining file name.
-
Full name including leading dot.
-
methods { Object<string, Method> }
-
Service methods.
-
methodsArray readonly{ Method[] }
-
Methods of this service as an array for iteration.
-
Unique name within its namespace.
-
nested { Object<string, ReflectionObject> | undefined }
-
Nested objects by name.
-
nestedArray readonly{ ReflectionObject[] }
-
Nested objects of this namespace as an array for iteration.
-
Options.
-
Parent namespace.
-
Parsed Options.
-
Whether already resolved or not.
-
Reference to the root namespace.
Methods
-
Adds a nested object to this namespace.
Parameters:
objectReflectionObject Nested object to add
Throws:
TypeError If arguments are invalid
Error If there is already a nested object with this name
Returns:
Namespace this -
Adds nested objects to this namespace from nested object descriptors.
Parameters:
nestedJsonObject.<string, AnyNestedObject> Any nested object descriptors
depthnumber optional Current nesting depth, defaults to
0Returns:
Namespace this -
create(rpcImpl, requestDelimited, responseDelimited){ rpc.Service }
-
Creates a runtime service using the specified rpc implementation.
Parameters:
rpcImplRPCImpl RPC implementation
requestDelimitedboolean false optional Whether requests are length-delimited
responseDelimitedboolean false optional Whether responses are length-delimited
Returns:
rpc.Service RPC service. Useful where requests and/or responses are streamed. -
Defines additial namespaces within this one if not yet existing.
Parameters:
pathstring | Array.<string> Path to create
json* optional Nested types to create from JSON
Returns:
Namespace Pointer to the last namespace created or thisif path is empty -
inherited get(name){ ReflectionObject | null }
-
Gets the nested object of the specified name.
Parameters:
namestring Nested object name
Returns:
ReflectionObject | null The reflection object or nullif it doesn't exist -
inherited getEnum(name){ Object<string, number> }
-
Gets the values of the nested enum of the specified name.
This methods differs from get in that it returns an enum's values directly and throws instead of returningnull.Parameters:
namestring Nested enum name
Throws:
Error If there is no such enum
Returns:
Object.<string, number> Enum values -
Gets an option value.
Parameters:
namestring Option name
Returns:
* Option value or undefinedif not set -
inherited lookup(path, filterTypes, parentAlreadyChecked){ ReflectionObject | null }
-
Recursively looks up the reflection object matching the specified path in the scope of this namespace.
Parameters:
pathstring | Array.<string> Path to look up
filterTypes* | Array.<*> Filter types, any combination of the constructors of
protobuf.Type,protobuf.Enum,protobuf.Serviceetc.parentAlreadyCheckedboolean false optional If known, whether the parent has already been checked
Returns:
ReflectionObject | null Looked up object or nullif none could be found -
inherited lookup(path, parentAlreadyChecked){ ReflectionObject | null }
-
Looks up the reflection object at the specified path, relative to this namespace.
Parameters:
pathstring | Array.<string> Path to look up
parentAlreadyCheckedboolean false optional Whether the parent has already been checked
Returns:
ReflectionObject | null Looked up object or nullif none could be found -
Looks up the values of the enum at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to an enumReturns:
Enum Looked up enum -
Looks up the service at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a serviceReturns:
Service Looked up service -
Looks up the type at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a typeReturns:
Type Looked up type -
Looks up the type or enum at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a type or enumReturns:
Type Looked up type or enum -
Called when this object is added to a parent.
Parameters:
parentReflectionObject Parent added to
Returns:
undefined -
Called when this object is removed from a parent.
Parameters:
parentReflectionObject Parent removed from
Returns:
undefined -
Removes a nested object from this namespace.
Parameters:
objectReflectionObject Nested object to remove
Throws:
TypeError If arguments are invalid
Error If
objectis not a member of this namespaceReturns:
Namespace this -
inherited resolve(){ ReflectionObject }
-
Resolves this objects type references.
Returns:
ReflectionObject this -
Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.
Returns:
Namespace this -
inherited setOption(name, value, ifNotSet){ ReflectionObject }
-
Sets an option.
Parameters:
namestring Option name
value* Option value
ifNotSetboolean | undefined optional Sets the option only if it isn't currently set
Returns:
ReflectionObject this -
inherited setOptions(options, ifNotSet){ ReflectionObject }
-
Sets multiple options.
Parameters:
optionsObject.<string, *> Options to set
ifNotSetboolean optional Sets an option only if it isn't currently set
Returns:
ReflectionObject this -
inherited setParsedOption(name, value, propName){ ReflectionObject }
-
Sets a parsed option.
Parameters:
namestring parsed Option name
value* Option value
propNamestring dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
Returns:
ReflectionObject this -
toJSON(toJSONOptions){ IService }
-
Converts this service to a service descriptor.
Parameters:
toJSONOptionsIToJSONOptions optional JSON conversion options
Returns:
IService Service descriptor -
Converts this instance to its string representation.
Returns:
string Class name[, space, full name] -
Service.fromJSON(name, json, depth){ Service }
-
Constructs a service from a service descriptor.
Parameters:
namestring Service name
jsonIService Service descriptor
depthnumber optional Current nesting depth, defaults to
0Throws:
TypeError If arguments are invalid
Returns:
Service Created service