Skip to content

Commit

Permalink
Drafted Monitor API
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Jan 17, 2022
1 parent 208d015 commit e709bde
Show file tree
Hide file tree
Showing 54 changed files with 11,009 additions and 403 deletions.
14 changes: 13 additions & 1 deletion .scripts/gen_code_proto.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#!/usr/bin/env sh
DIRNAME="$(cd "$(dirname "$0")"; pwd)"

PROTOS=(agents callmanager domains storage numbers providers funcs auth secrets users projects)
PROTOS=(
monitor \
agents \
callmanager \
domains \
storage \
numbers \
providers \
funcs \
auth \
secrets \
users \
projects)

for proto in "${PROTOS[@]}"
do
Expand Down
1 change: 1 addition & 0 deletions etc/rbac.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"name": "PROJECT",
"description": "Access to Project resources",
"access": [
"/fonoster.monitor.v1beta1.Monitor/SearchEvents",
"/fonoster.storage.v1beta1.Storage/UploadObject",
"/fonoster.storage.v1beta1.Storage/GetObjectURL",
"/fonoster.providers.v1beta1.Providers/ListProviders",
Expand Down
9 changes: 6 additions & 3 deletions etc/service_envs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
]
},
{
"module": "voice",
"env": []
"module": "monitor",
"env": [
"LOGS_AGGREGRATOR_HOST",
"LOGS_AGGREGRATOR_PORT"
]
}
]
]
95 changes: 95 additions & 0 deletions etc/vendor_protos/google/protobuf/struct.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "google.golang.org/protobuf/types/known/structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";

// `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct`
// might be supported by a native representation. For example, in
// scripting languages like JS a struct is represented as an
// object. The details of that representation are described together
// with the proto support for the language.
//
// The JSON representation for `Struct` is JSON object.
message Struct {
// Unordered map of dynamically typed values.
map<string, Value> fields = 1;
}

// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of these
// variants. Absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value {
// The kind of value.
oneof kind {
// Represents a null value.
NullValue null_value = 1;
// Represents a double value.
double number_value = 2;
// Represents a string value.
string string_value = 3;
// Represents a boolean value.
bool bool_value = 4;
// Represents a structured value.
Struct struct_value = 5;
// Represents a repeated `Value`.
ListValue list_value = 6;
}
}

// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
enum NullValue {
// Null value.
NULL_VALUE = 0;
}

// `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
message ListValue {
// Repeated field of dynamically typed values.
repeated Value values = 1;
}
2 changes: 1 addition & 1 deletion mods/agents/src/client/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
/**
* @classdesc Use Fonoster Agents, a capability of Fonoster SIP Proxy subsystem,
* to create, update, get and delete Agents. Agents requires of a
* runningFonosterdeployment.
* running Fonoster deployment.
*
* @extends APIClient
* @example
Expand Down
3 changes: 0 additions & 3 deletions mods/agents/src/service/protos/agents_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export class UpdateAgentRequest extends jspb.Message {
setRef(value: string): UpdateAgentRequest;
getName(): string;
setName(value: string): UpdateAgentRequest;
getUsername(): string;
setUsername(value: string): UpdateAgentRequest;
getSecret(): string;
setSecret(value: string): UpdateAgentRequest;
clearDomainsList(): void;
Expand All @@ -124,7 +122,6 @@ export namespace UpdateAgentRequest {
export type AsObject = {
ref: string,
name: string,
username: string,
secret: string,
domainsList: Array<string>,
privacy: string,
Expand Down
68 changes: 19 additions & 49 deletions mods/agents/src/service/protos/agents_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ proto.fonoster.agents.v1beta1.CreateAgentRequest.prototype.setPrivacy = function
* @private {!Array<number>}
* @const
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.repeatedFields_ = [5];
proto.fonoster.agents.v1beta1.UpdateAgentRequest.repeatedFields_ = [4];



Expand Down Expand Up @@ -874,10 +874,9 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.toObject = function(includeInst
var f, obj = {
ref: jspb.Message.getFieldWithDefault(msg, 1, ""),
name: jspb.Message.getFieldWithDefault(msg, 2, ""),
username: jspb.Message.getFieldWithDefault(msg, 3, ""),
secret: jspb.Message.getFieldWithDefault(msg, 4, ""),
domainsList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f,
privacy: jspb.Message.getFieldWithDefault(msg, 6, "")
secret: jspb.Message.getFieldWithDefault(msg, 3, ""),
domainsList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f,
privacy: jspb.Message.getFieldWithDefault(msg, 5, "")
};

if (includeInstance) {
Expand Down Expand Up @@ -923,18 +922,14 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.deserializeBinaryFromReader = f
msg.setName(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setUsername(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setSecret(value);
break;
case 5:
case 4:
var value = /** @type {string} */ (reader.readString());
msg.addDomains(value);
break;
case 6:
case 5:
var value = /** @type {string} */ (reader.readString());
msg.setPrivacy(value);
break;
Expand Down Expand Up @@ -981,31 +976,24 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.serializeBinaryToWriter = funct
f
);
}
f = message.getUsername();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
f = message.getSecret();
if (f.length > 0) {
writer.writeString(
4,
3,
f
);
}
f = message.getDomainsList();
if (f.length > 0) {
writer.writeRepeatedString(
5,
4,
f
);
}
f = message.getPrivacy();
if (f.length > 0) {
writer.writeString(
6,
5,
f
);
}
Expand Down Expand Up @@ -1049,29 +1037,11 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setName = function(va


/**
* optional string username = 3;
* @return {string}
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getUsername = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};


/**
* @param {string} value
* @return {!proto.fonoster.agents.v1beta1.UpdateAgentRequest} returns this
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setUsername = function(value) {
return jspb.Message.setProto3StringField(this, 3, value);
};


/**
* optional string secret = 4;
* optional string secret = 3;
* @return {string}
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getSecret = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};


Expand All @@ -1080,16 +1050,16 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getSecret = function(
* @return {!proto.fonoster.agents.v1beta1.UpdateAgentRequest} returns this
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setSecret = function(value) {
return jspb.Message.setProto3StringField(this, 4, value);
return jspb.Message.setProto3StringField(this, 3, value);
};


/**
* repeated string domains = 5;
* repeated string domains = 4;
* @return {!Array<string>}
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getDomainsList = function() {
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 5));
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 4));
};


Expand All @@ -1098,7 +1068,7 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getDomainsList = func
* @return {!proto.fonoster.agents.v1beta1.UpdateAgentRequest} returns this
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setDomainsList = function(value) {
return jspb.Message.setField(this, 5, value || []);
return jspb.Message.setField(this, 4, value || []);
};


Expand All @@ -1108,7 +1078,7 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setDomainsList = func
* @return {!proto.fonoster.agents.v1beta1.UpdateAgentRequest} returns this
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.addDomains = function(value, opt_index) {
return jspb.Message.addToRepeatedField(this, 5, value, opt_index);
return jspb.Message.addToRepeatedField(this, 4, value, opt_index);
};


Expand All @@ -1122,11 +1092,11 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.clearDomainsList = fu


/**
* optional string privacy = 6;
* optional string privacy = 5;
* @return {string}
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getPrivacy = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
};


Expand All @@ -1135,7 +1105,7 @@ proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.getPrivacy = function
* @return {!proto.fonoster.agents.v1beta1.UpdateAgentRequest} returns this
*/
proto.fonoster.agents.v1beta1.UpdateAgentRequest.prototype.setPrivacy = function(value) {
return jspb.Message.setProto3StringField(this, 6, value);
return jspb.Message.setProto3StringField(this, 5, value);
};


Expand Down
6 changes: 0 additions & 6 deletions mods/funcs/src/service/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import {runServices} from "@fonoster/common";
import {getSalt} from "@fonoster/certs";
import {FuncsService} from "./protos/funcs_grpc_pb";
import FuncsServer from "./funcs";
import logger from "@fonoster/logger";

if (!process.env.PUBLIC_URL) {
logger.error("Didn't find environment variable PUBLIC_URL while is required");
process.exit(1);
}

const services = [
{
Expand Down
2 changes: 1 addition & 1 deletion mods/googletts/test/tts.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("@fonoster/googletts", () => {
expect(synthesizeSpeech).to.not.have.been.called
})*/

it.only("synthesizes text or ssml and returns path to the new file", async () => {
it("synthesizes text or ssml and returns path to the new file", async () => {
const config = {
projectId: "clever-tube-275321",
keyFilename: "/Users/pedrosanders/Projects/fonoster/credentials.json"
Expand Down
Binary file added mods/monitor/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions mods/monitor/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Empty file.
6 changes: 6 additions & 0 deletions mods/monitor/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.nyc_output
coverage
src
test
*.log
11 changes: 11 additions & 0 deletions mods/monitor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM fonoster/base
COPY . /scripts
RUN ./install.sh
RUN link /usr/bin/run_monitor /usr/bin/run \
&& link /usr/bin/healthcheck_monitor /usr/bin/healthcheck
USER fonoster
HEALTHCHECK --interval=30s \
--timeout=30s \
--start-period=5s \
--retries=3 \
CMD [ "healthcheck" ]
Loading

0 comments on commit e709bde

Please sign in to comment.