...

Source file src/scheduler/faas_openfaas/types.go

Documentation: scheduler/faas_openfaas

     1  /*
     2   * P2PFaaS - A framework for FaaS Load Balancing
     3   * Copyright (c) 2019 - 2022. Gabriele Proietti Mattia <pm.gabriele@outlook.com>
     4   *
     5   * This program is free software: you can redistribute it and/or modify
     6   * it under the terms of the GNU General Public License as published by
     7   * the Free Software Foundation, either version 3 of the License, or
     8   * (at your option) any later version.
     9   *
    10   * This program is distributed in the hope that it will be useful,
    11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13   * GNU General Public License for more details.
    14   *
    15   * You should have received a copy of the GNU General Public License
    16   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
    17   */
    18  
    19  package faas_openfaas
    20  
    21  type Service struct {
    22  	OpenFaaSFunction Function `json:"openfaas_service,omitempty" bson:"openfaas_service"`
    23  	Deadline         uint64   `json:"deadline,omitempty" bson:"deadline"`
    24  }
    25  
    26  type CurrentLoad struct {
    27  	NumberOfServices       uint `json:"total_services" bson:"total_services"`
    28  	TotalReplicas          uint `json:"total_replicas" bson:"total_running_replicas"`
    29  	TotalAvailableReplicas uint `json:"total_available_replicas" bson:"total_available_replicas"`
    30  }
    31  
    32  type MachineResources struct {
    33  	Memory string `json:"memory,omitempty" bson:"memory"`
    34  	CPU    string `json:"cpu,omitempty" bson:"cpu"`
    35  }
    36  
    37  /*
    38  {
    39    "service": "nodeinfo",
    40    "network": "func_functions",
    41    "image": "functions/nodeinfo:latest",
    42    "envProcess": "node main.js",
    43    "envVars": {
    44      "additionalProp1": "string",
    45      "additionalProp2": "string",
    46      "additionalProp3": "string"
    47    },
    48    "constraints": [
    49      "node.platform.os == linux"
    50    ],
    51    "labels": [
    52      "string"
    53    ],
    54    "annotations": [
    55      "string"
    56    ],
    57    "secrets": [
    58      "secret-name-1"
    59    ],
    60    "registryAuth": "dXNlcjpwYXNzd29yZA==",
    61    "limits": {
    62      "memory": "128M",
    63      "cpu": "0.01"
    64    },
    65    "requests": {
    66      "memory": "128M",
    67      "cpu": "0.01"
    68    }
    69  }
    70  */
    71  
    72  type Function struct {
    73  	Name         string            `json:"name,omitempty" bson:"name"`
    74  	Service      string            `json:"service,omitempty" bson:"service"`
    75  	Network      string            `json:"network,omitempty" bson:"network"`
    76  	Image        string            `json:"image,omitempty" bson:"image"`
    77  	EnvProcess   string            `json:"envProcess,omitempty" bson:"envProcess"`
    78  	EnvVars      map[string]string `json:"envVars,omitempty" bson:"envVars"`
    79  	Constraints  []string          `json:"constraints,omitempty" bson:"constraints"`
    80  	Labels       map[string]string `json:"labels,omitempty" bson:"labels"`
    81  	Annotations  []string          `json:"annotations,omitempty" bson:"annotations"`
    82  	Secrets      []string          `json:"secrets,omitempty" bson:"secrets"`
    83  	RegistryAuth string            `json:"registryAuth,omitempty" bson:"registryAuth"`
    84  	Limits       MachineResources  `json:"limits,omitempty" bson:"limits"`
    85  	Requests     MachineResources  `json:"requests,omitempty" bson:"requests"`
    86  
    87  	InvocationCount   uint `json:"invocationCount,omitempty" bson:"invocationCount"`
    88  	Replicas          uint `json:"replicas,omitempty" bson:"replicas"`
    89  	AvailableReplicas uint `json:"availableReplicas,omitempty" bson:"availableReplicas"`
    90  }
    91  
    92  type FunctionScalePayload struct {
    93  	Service  string `json:"service,omitempty" bson:"service"`
    94  	Replicas uint   `json:"replicas,omitempty" bson:"replicas"`
    95  }
    96  
    97  /*
    98  type APIResponse struct {
    99  	Headers    http.Header
   100  	Body       []byte
   101  	StatusCode int
   102  }
   103  */
   104  

View as plain text