wa-lang.org/wazero@v1.0.2/imports/proxywasm/internal/abi_enums.go (about) 1 package internal 2 3 import ( 4 "errors" 5 "strconv" 6 7 "wa-lang.org/wazero/imports/proxywasm/types" 8 ) 9 10 type BufferType uint32 11 12 const ( 13 BufferTypeHttpRequestBody BufferType = 0 14 BufferTypeHttpResponseBody BufferType = 1 15 BufferTypeDownstreamData BufferType = 2 16 BufferTypeUpstreamData BufferType = 3 17 BufferTypeHttpCallResponseBody BufferType = 4 18 BufferTypeGrpcReceiveBuffer BufferType = 5 19 BufferTypeVMConfiguration BufferType = 6 20 BufferTypePluginConfiguration BufferType = 7 21 BufferTypeCallData BufferType = 8 22 ) 23 24 type LogLevel uint32 25 26 const ( 27 LogLevelTrace LogLevel = 0 28 LogLevelDebug LogLevel = 1 29 LogLevelInfo LogLevel = 2 30 LogLevelWarn LogLevel = 3 31 LogLevelError LogLevel = 4 32 LogLevelCritical LogLevel = 5 33 LogLevelMax LogLevel = 6 34 ) 35 36 func (l LogLevel) String() string { 37 switch l { 38 case LogLevelTrace: 39 return "trace" 40 case LogLevelDebug: 41 return "debug" 42 case LogLevelInfo: 43 return "info" 44 case LogLevelWarn: 45 return "warn" 46 case LogLevelError: 47 return "error" 48 case LogLevelCritical: 49 return "critical" 50 default: 51 panic("invalid log level") 52 } 53 } 54 55 type MapType uint32 56 57 const ( 58 MapTypeHttpRequestHeaders MapType = 0 59 MapTypeHttpRequestTrailers MapType = 1 60 MapTypeHttpResponseHeaders MapType = 2 61 MapTypeHttpResponseTrailers MapType = 3 62 MapTypeHttpCallResponseHeaders MapType = 6 63 MapTypeHttpCallResponseTrailers MapType = 7 64 ) 65 66 type MetricType uint32 67 68 const ( 69 MetricTypeCounter = 0 70 MetricTypeGauge = 1 71 MetricTypeHistogram = 2 72 ) 73 74 type StreamType uint32 75 76 const ( 77 StreamTypeRequest StreamType = 0 78 StreamTypeResponse StreamType = 1 79 StreamTypeDownstream StreamType = 2 80 StreamTypeUpstream StreamType = 3 81 ) 82 83 type Status uint32 84 85 const ( 86 StatusOK Status = 0 87 StatusNotFound Status = 1 88 StatusBadArgument Status = 2 89 StatusEmpty Status = 7 90 StatusCasMismatch Status = 8 91 StatusInternalFailure Status = 10 92 StatusUnimplemented Status = 12 93 ) 94 95 //go:inline 96 func StatusToError(status Status) error { 97 switch Status(status) { 98 case StatusOK: 99 return nil 100 case StatusNotFound: 101 return types.ErrorStatusNotFound 102 case StatusBadArgument: 103 return types.ErrorStatusBadArgument 104 case StatusEmpty: 105 return types.ErrorStatusEmpty 106 case StatusCasMismatch: 107 return types.ErrorStatusCasMismatch 108 case StatusInternalFailure: 109 return types.ErrorInternalFailure 110 case StatusUnimplemented: 111 return types.ErrorUnimplemented 112 } 113 return errors.New("unknown status code: " + strconv.Itoa(int(status))) 114 }