package uid

import (
	"context"
	"os"

	"github.com/go-kratos/kratos/v2"
)

// GetAppId 获取应用id
func GetAppId(ctx context.Context) string {
	appId := ""
	appInfo, ok := kratos.FromContext(ctx)
	if ok {
		appId = appInfo.ID()
	} else {
		appId, _ = os.Hostname()
	}
	return appId
}
