github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/runtime/local/process/process.go (about) 1 // Licensed under the Apache License, Version 2.0 (the "License"); 2 // you may not use this file except in compliance with the License. 3 // You may obtain a copy of the License at 4 // 5 // https://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, 9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 // See the License for the specific language governing permissions and 11 // limitations under the License. 12 // 13 // Original source: github.com/micro/go-micro/v3/runtime/local/process/process.go 14 15 // Package process executes a binary 16 package process 17 18 import ( 19 "io" 20 ) 21 22 // Process manages a running process 23 type Process interface { 24 // Executes a process to completion 25 Exec(*Binary) error 26 // Creates a new process 27 Fork(*Binary) (*PID, error) 28 // Kills the process 29 Kill(*PID) error 30 // Waits for a process to exit 31 Wait(*PID) error 32 } 33 34 type Binary struct { 35 // Package containing executable 36 Package *Package 37 // The env variables 38 Env []string 39 // Args to pass 40 Args []string 41 // Initial working directory 42 Dir string 43 } 44 45 // Source is the source of a build 46 type Source struct { 47 // Path to the source if local 48 Path string 49 // Language is the language of code 50 Language string 51 // Location of the source 52 Repository string 53 } 54 55 // Package is packaged format for source 56 type Package struct { 57 // Name of the package 58 Name string 59 // Location of the package 60 Path string 61 // Type of package e.g tarball, binary, docker 62 Type string 63 // Source of the package 64 Source *Source 65 } 66 67 // PID is the running process 68 type PID struct { 69 // ID of the process 70 ID string 71 // Stdin 72 Input io.Writer 73 // Stdout 74 Output io.Reader 75 // Stderr 76 Error io.Reader 77 }