...

Source file src/scheduler/types/api.go

Documentation: scheduler/types

     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 types
    20  
    21  import (
    22  	"net/http"
    23  	"time"
    24  )
    25  
    26  type Load struct {
    27  	// general info
    28  	SchedulerName string `json:"scheduler_name"`
    29  	// functions-related
    30  	FunctionsDeployed      uint `json:"functions_deployed"`
    31  	FunctionsTotalReplicas uint `json:"functions_total_replicas"`
    32  	FunctionsRunning       uint `json:"functions_running"`
    33  	FunctionsRunningMax    uint `json:"functions_running_max"`
    34  	// queue-related
    35  	QueueLengthMax uint `json:"queue_max_length"`
    36  	QueueFill      int  `json:"queue_fill"`
    37  }
    38  
    39  type PeerJobRequest struct {
    40  	// Function    faas_containers-openfaas.Function     `json:"function"`     // the function that we want to execute
    41  	ServiceIdRequest uint64            `json:"service_id_request"` // the service request id
    42  	ServiceIdTracing string            `json:"service_id_tracing"` // the service request tracing id
    43  	FunctionName     string            `json:"function_name"`      // the function name to execute
    44  	Hops             int               `json:"hops"`               // number of times the job is forwarded
    45  	PeersList        []PeersListMember `json:"peers_list"`         // list of peers that handled the job
    46  	Payload          string            `json:"payload"`            // the payload of the request in base64 string
    47  	ContentType      string            `json:"content_type"`       // the mime type of the payload
    48  	Headers          map[string]string `json:"headers"`            // the headers to add to the peer job request
    49  }
    50  
    51  type PeerJobResponse struct {
    52  	PeersList  []PeersListMember `json:"peers_list"`  // list of peers that handled the job
    53  	Body       string            `json:"body"`        // base64 encoded
    54  	StatusCode int               `json:"status_code"` // job response status code
    55  }
    56  
    57  type PeersListMember struct {
    58  	MachineId string  `json:"machine_id"`
    59  	MachineIp string  `json:"machine_ip"`
    60  	Timings   Timings `json:"timings"` // timing referred to the passage in that machine
    61  }
    62  
    63  type TimingsStart struct {
    64  	ArrivedAt        *time.Time `json:"arrived_at,omitempty"`         // time at which job arrives
    65  	ProbingStartedAt *time.Time `json:"started_probing_at,omitempty"` // time at which probing is started
    66  	ProbingEndedAt   *time.Time `json:"ended_probing_at,omitempty"`   // time at which probing is ended
    67  	ScheduledAt      *time.Time `json:"scheduled_at,omitempty"`       // time at which job is scheduled internally or externally
    68  }
    69  
    70  type Timings struct {
    71  	ExecutionTime  *float64 `json:"execution_time,omitempty"`  // the time of executing the job comprising the GET to openfaas
    72  	TotalTime      *float64 `json:"total_time,omitempty"`      // elapsed time from job arrival til its completed execution
    73  	SchedulingTime *float64 `json:"scheduling_time,omitempty"` // elapsed time for a job to be scheduled
    74  	ProbingTime    *float64 `json:"probing_time,omitempty"`    // elapsed time for a job to probe other nodes
    75  }
    76  
    77  type APIResponse struct {
    78  	Headers    http.Header `json:"headers"`
    79  	Body       []byte      `json:"body"`
    80  	StatusCode int         `json:"status_code"`
    81  }
    82  

View as plain text