1234567891011121314151617181920212223242526272829303132333435363738 |
- package service
- import (
- "fmt"
- "github.com/google/uuid"
- )
- const (
- META = "service"
- )
- func NewPool(services ...Service) (pool map[string]Service) {
- pool = make(map[string]Service)
- for i := range services {
- if services[i] == nil {
- continue
- }
- sid := services[i].String()
- if sid == "" {
- sid = uuid.NewString()
- }
- pool[sid] = services[i]
- }
- return
- }
- func Pool(v any) (map[string]Service, error) {
- pool, ok := v.(map[string]Service)
- if !ok {
- return nil, fmt.Errorf("illegal state: could not extract service pool")
- }
- return pool, nil
- }
|