func (s *Server) set(state *State) error {
	log.Debug("updating introspection data...")
	s.state = state
	data, err := json.Marshal(s.state)
	if err != nil {
		err = introspectError("failed to marshal state for introspection: %v", err)
		s.state = &State{Error: fmt.Sprintf("%v", err)}
		data, _ = json.Marshal(s.state)
	}
	s.data = string(data)
	return err
}
set sets the given state and encodes it as a JSON string.
package introspect
import (
	"encoding/json"
	"fmt"
	"net/http"
	"sync"
	xhttp "github.com/intel/cri-resource-manager/pkg/instrumentation/http"
	logger "github.com/intel/cri-resource-manager/pkg/log"
	"github.com/intel/cri-resource-manager/pkg/topology"
)
type Pod struct {
	ID         string                 
	UID        string                 
	Name       string                 
	Containers map[string]*Container  
}
type Container struct {
	ID            string         
	Name          string         
	Command       []string       
	Args          []string       
	CPURequest    int64          
	CPULimit      int64          
	MemoryRequest int64          
	MemoryLimit   int64          
	Hints         TopologyHints  
}
type TopologyHints topology.Hints
type Assignment struct {
	ContainerID   string  
	SharedCPUs    string  
	CPUShare      int     
	ExclusiveCPUs string  
	Memory        string  
	Pool          string  
}
type Pool struct {
	Name     string    
	CPUs     string    
	Memory   string    
	Parent   string    
	Children []string  
}
type Socket struct {
	ID   int     
	CPUs string  
}
type Node struct {
	ID   int     
	CPUs string  
}
type System struct {
	Sockets        map[int]*Socket  
	Nodes          map[int]*Node    
	Isolated       string           
	Offlined       string           
	RDTClasses     []string         
	BlockIOClasses []string         
	Policy         string           
}
type State struct {
	Pools       map[string]*Pool        
	Pods        map[string]*Pod         
	Assignments map[string]*Assignment  
	System      *System                 
	Error       string
}
var log = logger.NewLogger("instrospect")
type Server struct {
	sync.RWMutex                  
	mux          *xhttp.ServeMux  
	state        *State           
	data         string           
	ready        bool
}
func Setup(mux *xhttp.ServeMux, state *State) (*Server, error) {
	s := &Server{mux: mux}
	if err := s.set(state); err != nil {
		return nil, err
	}
	mux.HandleFunc("/introspect", s.serve)
	return s, nil
}
func (s *Server) Set(state *State) error {
	s.Lock()
	defer s.Unlock()
	return s.set(state)
}
func (s *Server) Start() {
	log.Info("starting introspection server...")
	s.ready = true
}
func (s *Server) Stop() {
	log.Info("stopping introspection server...")
	s.ready = false
}