console.go 558 字节
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6 7 8 9 10
package console

import (
	"context"
	"sync"
)

//Console console
type Console struct {
	adminHost   string
Y
Your Name 已提交
11
	instance        string
Y
Your Name 已提交
12 13 14 15 16 17 18 19 20 21 22 23
	ctx         context.Context
	cancel      context.CancelFunc
	lastVersion int
	once        sync.Once
}

//Close close
func (c *Console) Close() {
	c.once.Do(c.cancel)
}

//NewConsole newConsole
Y
Your Name 已提交
24
func NewConsole(instance string, adminHost string) *Console {
Y
Your Name 已提交
25 26
	ctx, cancel := context.WithCancel(context.Background())
	return &Console{
Y
Your Name 已提交
27
		instance:      instance,
Y
Your Name 已提交
28 29 30 31 32
		adminHost: adminHost,
		ctx:       ctx,
		cancel:    cancel,
	}
}