github.com/dbernstein1/tyk@v2.9.0-beta9-dl-apic+incompatible/coprocess/native_dispatcher.go (about)

     1  // +build coprocess
     2  // +build !grpc
     3  
     4  package coprocess
     5  
     6  /*
     7  #include <stdio.h>
     8  
     9  #include "sds/sds.h"
    10  
    11  #include "api.h"
    12  
    13  */
    14  import "C"
    15  import "unsafe"
    16  
    17  import (
    18  	"github.com/TykTechnologies/tyk/apidef"
    19  )
    20  
    21  const (
    22  	_ = iota
    23  	JsonMessage
    24  	ProtobufMessage
    25  )
    26  
    27  // Dispatcher defines a basic interface for the CP dispatcher, check PythonDispatcher for reference.
    28  type Dispatcher interface {
    29  	// Dispatch takes and returns a pointer to a CoProcessMessage struct, see coprocess/api.h for details. This is used by CP bindings.
    30  	Dispatch(unsafe.Pointer, unsafe.Pointer) error
    31  
    32  	// DispatchEvent takes an event JSON, as bytes. Doesn't return.
    33  	DispatchEvent([]byte)
    34  
    35  	// DispatchObject takes and returns a coprocess.Object pointer, this is used by gRPC.
    36  	DispatchObject(*Object) (*Object, error)
    37  
    38  	// LoadModules is called the first time a CP binding starts. Used by Lua.
    39  	LoadModules()
    40  
    41  	// HandleMiddlewareCache is called when a bundle has been loaded and the dispatcher needs to cache its contents. Used by Lua.
    42  	HandleMiddlewareCache(*apidef.BundleManifest, string)
    43  
    44  	// Reload is called when a hot reload is triggered. Used by all the CPs.
    45  	Reload()
    46  }