wa-lang.org/wazero@v1.0.2/imports/proxywasm/types/types.go (about)

     1  // Copyright 2020-2021 Tetrate
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package types
    16  
    17  import "errors"
    18  
    19  // Action represents the action which Wasm contexts expects hosts to take.
    20  type Action uint32
    21  
    22  const (
    23  	// ActionContinue means that the host continues the processing.
    24  	ActionContinue Action = 0
    25  	// ActionPause means that the host pauses the processing.
    26  	ActionPause Action = 1
    27  )
    28  
    29  // PeerType represents the type of a peer of a connection.
    30  type PeerType uint32
    31  
    32  const (
    33  	// PeerTypeUnknown means the type of a peer is unknown
    34  	PeerTypeUnknown PeerType = 0
    35  	// PeerTypeLocal means the type of a peer is local (i.e. proxy)
    36  	PeerTypeLocal PeerType = 1
    37  	// PeerTypeRemote means the type of a peer is remote (i.e. remote client)
    38  	PeerTypeRemote PeerType = 2
    39  )
    40  
    41  // OnVMStartStatus is the type of status returned by OnVMStart
    42  type OnVMStartStatus bool
    43  
    44  const (
    45  	// OnVMStartStatusOK indicates that VMContext.OnVMStartStatus succeeded.
    46  	OnVMStartStatusOK OnVMStartStatus = true
    47  	// OnVMStartStatusFailed indicates that VMContext.OnVMStartStatus failed.
    48  	// Further processing for this VM never happens, and hosts would
    49  	// delete this VM.
    50  	OnVMStartStatusFailed OnVMStartStatus = false
    51  )
    52  
    53  // OnPluginStartStatus is the type of status returned by OnPluginStart
    54  type OnPluginStartStatus bool
    55  
    56  const (
    57  	// OnPluginStartStatusOK indicates that PluginContext.OnPluginStart succeeded.
    58  	OnPluginStartStatusOK OnPluginStartStatus = true
    59  	// OnPluginStartStatusFailed indicates that PluginContext.OnPluginStart failed.
    60  	// Further processing for this plugin context never happens.
    61  	OnPluginStartStatusFailed OnPluginStartStatus = false
    62  )
    63  
    64  var (
    65  	// ErrorStatusNotFound means not found for various hostcalls.
    66  	ErrorStatusNotFound = errors.New("error status returned by host: not found")
    67  	// ErrorStatusBadArgument means the arguments for a hostcall are invalid.
    68  	ErrorStatusBadArgument = errors.New("error status returned by host: bad argument")
    69  	// ErrorStatusEmpty means the target queue of DequeueSharedQueue call is empty.
    70  	ErrorStatusEmpty = errors.New("error status returned by host: empty")
    71  	// ErrorStatusCasMismatch means the CAS value provided to the SetSharedData
    72  	// does not match the current value. It indicates that other Wasm VMs
    73  	// have already set a value for the same key, and the current CAS
    74  	// for the key gets incremented.
    75  	// Having retry logic in the face of this error is recommended.
    76  	ErrorStatusCasMismatch = errors.New("error status returned by host: cas mismatch")
    77  	// ErrorInternalFailure indicates an internal failure in hosts.
    78  	// When this error occurs, there's nothing we could do in the Wasm VM.
    79  	// Abort or panic after this error is recommended.
    80  	ErrorInternalFailure = errors.New("error status returned by host: internal failure")
    81  	// ErrorUnimplemented indicates the API is not implemented in the host yet.
    82  	ErrorUnimplemented = errors.New("error status returned by host: unimplemented")
    83  )