github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/aagent/model/machine.go (about)

     1  // Copyright (c) 2021-2022, R.I. Pienaar and the Choria Project contributors
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package model
     6  
     7  import (
     8  	"encoding/json"
     9  
    10  	"github.com/choria-io/go-choria/lifecycle"
    11  	"github.com/nats-io/jsm.go"
    12  )
    13  
    14  type MachineConstructor interface {
    15  	Name() string
    16  	Machine() any
    17  	PluginName() string
    18  }
    19  
    20  type Machine interface {
    21  	State() string
    22  	Transition(t string, args ...any) error
    23  	NotifyWatcherState(string, any)
    24  	Name() string
    25  	Directory() string
    26  	TextFileDirectory() string
    27  	Identity() string
    28  	InstanceID() string
    29  	Version() string
    30  	TimeStampSeconds() int64
    31  	OverrideData() ([]byte, error)
    32  	ChoriaStatusFile() (string, int)
    33  	JetStreamConnection() (*jsm.Manager, error)
    34  	PublishLifecycleEvent(t lifecycle.Type, opts ...lifecycle.Option)
    35  	MainCollective() string
    36  	Facts() json.RawMessage
    37  	Data() map[string]any
    38  	DataPut(key string, val any) error
    39  	DataGet(key string) (any, bool)
    40  	DataDelete(key string) error
    41  	SignerKey() string
    42  	Debugf(name string, format string, args ...any)
    43  	Infof(name string, format string, args ...any)
    44  	Warnf(name string, format string, args ...any)
    45  	Errorf(name string, format string, args ...any)
    46  }