github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/models/strategy.go (about)

     1  package models
     2  
     3  import (
     4  	"github.com/machinefi/w3bstream/pkg/depends/base/types"
     5  	"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx/datatypes"
     6  	"github.com/machinefi/w3bstream/pkg/enums"
     7  )
     8  
     9  // Strategy event route strategy
    10  // @def primary                       ID
    11  // @def unique_index UI_strategy_id   StrategyID
    12  // @def unique_index UI_prj_app_event ProjectID AppletID EventType
    13  //
    14  //go:generate toolkit gen model Strategy --database DB
    15  type Strategy struct {
    16  	datatypes.PrimaryID
    17  	RelStrategy
    18  	RelProject
    19  	RelApplet
    20  	StrategyInfo
    21  	datatypes.OperationTimesWithDeleted
    22  }
    23  
    24  type RelStrategy struct {
    25  	StrategyID types.SFID `db:"f_strategy_id" json:"strategyID"`
    26  }
    27  
    28  type StrategyInfo struct {
    29  	// EventType user defined event type
    30  	EventType string `db:"f_event_type" json:"eventType"`
    31  	// Handler wasm handler fn name
    32  	Handler string `db:"f_handler" json:"handler"`
    33  	// AutoCollectMetric if allow host collect event data for metering
    34  	AutoCollectMetric datatypes.Bool `db:"f_auto_collect_metric,default='2'" json:"autoCollectMetric,omitempty"`
    35  }
    36  
    37  var DefaultStrategyInfo = StrategyInfo{
    38  	EventType:         enums.EVENTTYPEDEFAULT,
    39  	Handler:           "start",
    40  	AutoCollectMetric: datatypes.FALSE,
    41  }