• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang common.LocalID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/KiiPlatform/gateway-agent/internal/common.LocalID函数的典型用法代码示例。如果您正苦于以下问题:Golang LocalID函数的具体用法?Golang LocalID怎么用?Golang LocalID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LocalID函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: RestoreGatewayApp

// RestoreGatewayApp restores the Gateway App
func (m *Mapper) RestoreGatewayApp() error {
	// return err when current state of gateway app is not WaitingRestore
	if err := m.StateTable.CheckGatewayState(state.WaitingRestore); err != nil {
		return state.ErrNotWaitingRestore
	}

	if err := m.StateTable.ChangeGatewayState(state.Restoring,
		common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID)); err != nil {
		return err
	}

	// change back to WaitingRestore only err happened during restoring gateway app
	hanleErr := func(err error) error {
		m.StateTable.ChangeGatewayState(state.WaitingRestore,
			common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID))
		return err
	}

	// disconnect all connecting mqtt clients
	m.Cloud.DisconnectAllMQTTClients()
	// clear DB
	if err := m.Store.ClearDB(); err != nil {
		return hanleErr(err)
	}

	// onboard with gateway app
	if _, err := m.onboardgatewayApp(); err != nil {
		return hanleErr(err)
	}

	// restore gateway
	if err := m.restoreGateway(m.Config.MasterApp.Site, m.Config.MasterApp.AppID); err != nil {
		return hanleErr(err)
	}

	// change state of gateway app to DoneOnboard after restore
	if err := m.StateTable.ChangeGatewayState(state.DoneOnboard,
		common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID)); err != nil {
		return hanleErr(err)
	}

	// Restore all the end-node apps saved on cloud
	apps, err := m.ListAllEndnodeApps()
	if err != nil {
		return err
	}
	for _, a := range apps {
		m.StateTable.ChangeAppState(state.Restoring, common.LocalID(common.LocalAppID(a.ServerLocation, a.AppID)))
		err = m.RestoreEndnodeApp(a)
		if err != nil {
			return err
		}
		m.StateTable.ChangeAppState(state.DoneOnboard, common.LocalID(common.LocalAppID(a.ServerLocation, a.AppID)))
	}

	//change restoreMode to false
	m.StateTable.RestoreMode = false
	return nil
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:60,代码来源:mapper.go


示例2: TestOnboardEndnodeAppMapper_gatewayNotReady

func TestOnboardEndnodeAppMapper_gatewayNotReady(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	app := common.App{
		AppID:          "app67890",
		AppKey:         "app0987654321abcdefghijklmn",
		ServerLocation: "jp",
	}
	mapper.StateTable = &state.Table{
		Gateway: state.Onboarding,
		Apps: map[common.LocalID]state.State{
			common.LocalID(app.LocalID()): state.DoneOnboard,
		},
	}
	id, err := mapper.OnboardEndnodeApp(app)
	if err == nil {
		t.Fatal("should fail")
	}
	if id != "" {
		t.Fatal("id should be empty")
	}
	if err.Error() != "state is expected one of DONE_ONBOARD but actual: UNKNONWD_STATE" {
		t.Fatal("fail with unexpected error", err)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:25,代码来源:mapper_test.go


示例3: TestOnboardEndnodeAppMapper_restoringGateway

func TestOnboardEndnodeAppMapper_restoringGateway(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	app := common.App{
		AppID:          "app67890",
		AppKey:         "app0987654321abcdefghijklmn",
		ServerLocation: "jp",
	}
	restoreStates := []state.State{state.WaitingRestore, state.Restoring}
	for _, s := range restoreStates {

		mapper.StateTable = &state.Table{
			Gateway: s,
			Apps: map[common.LocalID]state.State{
				common.LocalID(app.LocalID()): state.WaitingRestore,
			},
			RestoreMode: true,
		}
		id, err := mapper.OnboardEndnodeApp(app)
		if err == nil {
			t.Fatal("should fail")
		}
		if id != "" {
			t.Fatal("id should be empty")
		}
		if err.Error() != "state isn't expected one of WAITING_RESTORE nor RESTORING but actual: UNKNONWD_STATE" {
			t.Fatal("fail with unexpected error", err)
		}
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:30,代码来源:mapper_test.go


示例4: TestPendingEndnodesMapper_restoringGateway

func TestPendingEndnodesMapper_restoringGateway(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()

	restoreStates := []state.State{state.WaitingRestore, state.Restoring}
	for _, s := range restoreStates {
		mapper.StateTable = &state.Table{
			Gateway: s,
			Apps: map[common.LocalID]state.State{
				common.LocalID(common.LocalAppID("jp", "app67890")): state.WaitingRestore,
			},
			RestoreMode: true,
		}
		nodes, err := mapper.PendingEndnodes("jp", "app67890")
		if err == nil {
			t.Fatal("should fail")
		}
		if err.Error() != "state isn't expected one of WAITING_RESTORE nor RESTORING but actual: UNKNONWD_STATE" {
			t.Fatal("fail with unexpected error", err)
		}
		if len(nodes) != 0 {
			t.Fatal("nodes should not have items")
		}
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:25,代码来源:mapper_test.go


示例5: TestReplaceEndnodeMapper_basic

func TestReplaceEndnodeMapper_basic(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.DoneOnboard,
		},
	}
	err := mapper.ReplaceEndnode("jp", "app67890", "T0001endnode", "th.0001endnode")
	if err != nil {
		t.Fatal("TestReplaceEndnodeMapper_basic failed", err)
	}
	if mapper.store.caddr.AppID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.store.caddr.AppID)
	}
	if mapper.store.caddr.ServerLocation != "jp" {
		t.Error("ServerLocation should be \"jp\":", mapper.store.caddr.ServerLocation)
	}
	if mapper.store.caddr.ThingID != "th.0001endnode" {
		t.Error("ThingID should be \"th.0001endnode\":", mapper.store.caddr.ThingID)
	}
	if mapper.store.ea.AppID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.store.ea.AppID)
	}
	if mapper.store.ea.ServerLocation != "jp" {
		t.Error("ServerLocation should be \"jp\":", mapper.store.ea.ServerLocation)
	}
	if mapper.store.ea.VendorThingID != "T0001endnode" {
		t.Error("VendorThingID should be \"T0001endnode\":", mapper.store.ea.VendorThingID)
	}

}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:33,代码来源:mapper_test.go


示例6: TestRestoreGatewayApp_ENAppFail

func TestRestoreGatewayApp_ENAppFail(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	allEndnodes := []common.App{
		{ServerLocation: "jp", AppID: "id1", AppKey: "key1"},
	}
	mapper.StateTable = &state.Table{
		Gateway: state.WaitingRestore,
		Apps:    map[common.LocalID]state.State{},
	}

	mapper.cloud.err4OnboardEndnodeApp = errors.New("onboard endnode app fail")
	mapper.cloud.apps4ListAllEndnodeApps = allEndnodes
	err := mapper.RestoreGatewayApp()
	if err == nil {
		t.Error("should fail", err)
	} else {
		if err.Error() != "onboard endnode app fail" {
			t.Error("fail with other error", err)
		}
	}
	if mapper.StateTable.Gateway != state.DoneOnboard {
		t.Error("state of gateway app should be DoneOnboard", mapper.StateTable.Gateway)
	}
	enState := mapper.StateTable.Apps[common.LocalID(common.LocalAppID("jp", "id1"))]
	if enState != state.Restoring {
		t.Error("state of endnode app is not Restoring", enState)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:29,代码来源:mapper_test.go


示例7: TestOnboardEndnodeAppMapper_wrongPassword

func TestOnboardEndnodeAppMapper_wrongPassword(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	app := common.App{
		AppID:          "app67890",
		AppKey:         "app0987654321abcdefghijklmn",
		ServerLocation: "jp",
	}
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(app.LocalID()): state.DoneOnboard,
		},
	}
	mapper.cloud.err4OnboardEndnodeApp = common.ErrWrongPassword
	id, err := mapper.OnboardEndnodeApp(app)
	if err == nil {
		t.Fatal("should fail")
	}
	if id != "" {
		t.Fatal("id should be empty")
	}
	if err.Error() != "wrong password of gateway" {
		t.Fatal("fail with unexpected error", err)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:26,代码来源:mapper_test.go


示例8: TestOnboardEndnodeAppMapper_basic

// test OnboardEndnodeApp
func TestOnboardEndnodeAppMapper_basic(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	app := common.App{
		AppID:          "app67890",
		AppKey:         "app0987654321abcdefghijklmn",
		ServerLocation: "jp",
	}
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(app.LocalID()): state.WaitingOnboard,
		},
	}
	id, err := mapper.OnboardEndnodeApp(app)
	if err != nil {
		t.Fatal("TestOnboardEndnodeAppMapper_basic failed", err)
	}
	if id != "th.0001endnode" {
		t.Error("ThingID should be \"th.0001endnode\":", id)
	}
	if mapper.store.appID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.store.appID)
	}
	if mapper.cloud.app.AppID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.cloud.app.AppID)
	}
	if mapper.cloud.app.AppKey != "app0987654321abcdefghijklmn" {
		t.Error("AppKey should be \"app0987654321abcdefghijklmn\":", mapper.cloud.app.AppKey)
	}
	if mapper.cloud.app.ServerLocation != "jp" {
		t.Error("ServerLocation should be \"jp\":", mapper.cloud.app.ServerLocation)
	}
	if mapper.cloud.called4SaveEndnodeApp != true {
		t.Error("endnode app should be saved on gateway app")
	}

	if mapper.StateTable.Apps[common.LocalID(app.LocalID())] != state.DoneOnboard {
		t.Fatal("endnode app should be DoneOnboard", mapper.StateTable.Apps[common.LocalID(app.LocalID())])
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:42,代码来源:mapper_test.go


示例9: LoadTable

// LoadTable load state table from store
func LoadTable(s store.Store, gwID common.LocalID, restoreMode bool) (*Table, error) {
	allStates := map[common.LocalID]State{}

	onboardedApps, err := s.GetAllOnboardedApp()
	if err != nil {
		return nil, err
	}

	// defaultState is for the gateway already onboarded
	var defaultState State
	if restoreMode {
		defaultState = WaitingRestore
	} else {
		defaultState = DoneOnboard
	}

	var gwState State
	for _, gateway := range onboardedApps {
		if gwID == common.LocalID(gateway.LocalID()) {
			gwState = defaultState
		}
		allStates[common.LocalID(gateway.LocalID())] = defaultState
	}

	// if gateway is not onboarded, the value under normal mode is WaitingOnboard
	if gwState == 0 {
		if restoreMode {
			gwState = WaitingRestore
		} else {
			gwState = WaitingOnboard
		}
	}
	st := &Table{
		Gateway:     gwState,
		Apps:        allStates,
		RestoreMode: restoreMode,
	}
	return st, nil
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:40,代码来源:state_table.go


示例10: OnboardEndnodeApp

// OnboardEndnodeApp onboards the Gateway for the Endnode App
func (m *Mapper) OnboardEndnodeApp(app common.App) (string, error) {

	if app.ServerLocation == m.Config.MasterApp.Site && app.AppID == m.Config.MasterApp.AppID {
		return m.OnboardGatewayApp()
	}
	// verify state first
	if m.StateTable.RestoreMode {
		return "", state.ErrRestoringGateway
	}
	// if gateway state is not DoneOnboard, then resturn err
	if err := m.StateTable.CheckGatewayState(state.DoneOnboard); err != nil {
		return "", state.ErrGatewayAppGatewayNotReady
	}
	if err := m.StateTable.CheckAppState(common.LocalID(app.LocalID()), state.Onboarding); err == nil {
		return "", state.ErrOnboarding
	}

	// change state of endnode app to onboarding before onboard
	if err := m.StateTable.ChangeAppState(state.Onboarding, common.LocalID(app.LocalID())); err != nil {
		return "", err
	}

	handleErr := func(err error) (string, error) {
		m.StateTable.ChangeAppState(state.WaitingOnboard, common.LocalID(app.LocalID()))
		return "", err
	}
	gwID, err := m.onboardGateway(app, true)
	if err != nil {
		return handleErr(err)
	}

	// change state of endnode app to DoneOnboard after onboard
	if err := m.StateTable.ChangeAppState(state.DoneOnboard, common.LocalID(app.LocalID())); err != nil {
		return handleErr(err)
	}

	return gwID, nil
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:39,代码来源:mapper.go


示例11: TestCompleteEndnodeOnboardingMapper_ENAppNotDoneOnboard

func TestCompleteEndnodeOnboardingMapper_ENAppNotDoneOnboard(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()

	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.Onboarding,
		},
	}
	err := mapper.CompleteEndnodeOnboarding("jp", "app67890", "T0001endnode", "th.0001endnode")
	if err == nil {
		t.Fatal("TestCompleteEndnodeOnboardingMapper_restoringGateway should fail")
	}
	if err.Error() != "state is expected one of DONE_ONBOARD but actual: UNKNONWD_STATE" {
		t.Fatal("fail with other error", err)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:18,代码来源:mapper_test.go


示例12: TestGetGatewayIDMapper_basic

// test GetGatewayID
func TestGetGatewayIDMapper_basic(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.DoneOnboard,
		},
	}
	id, err := mapper.GetGatewayID("jp", "app67890")
	if err != nil {
		t.Fatal("TestGetGatewayIDMapper_basic failed", err)
	}
	if id != "th.0002gateway" {
		t.Error("ThingID should be \"th.0002gateway\":", id)
	}
	if mapper.store.appID4FindGatewayByAppID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.store.appID)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:21,代码来源:mapper_test.go


示例13: TestGetGatewayIDMapper_ENAppNotDoneOnboard

func TestGetGatewayIDMapper_ENAppNotDoneOnboard(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.Onboarding,
		},
	}
	id, err := mapper.GetGatewayID("jp", "app67890")
	if err == nil {
		t.Fatal("should fail")
	}

	if id != "" {
		t.Fatal("id should be empty")
	}
	if err.Error() != "state is expected one of DONE_ONBOARD but actual: UNKNONWD_STATE" {
		t.Fatal("faild with other error", err)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:21,代码来源:mapper_test.go


示例14: TestPendingEndnodesMapper_gatewayNotReady

func TestPendingEndnodesMapper_gatewayNotReady(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()

	mapper.StateTable = &state.Table{
		Gateway: state.Onboarding,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.DoneOnboard,
		},
	}
	nodes, err := mapper.PendingEndnodes("jp", "app67890")
	if err == nil {
		t.Fatal("should fail")
	}
	if err.Error() != "state is expected one of DONE_ONBOARD but actual: UNKNONWD_STATE" {
		t.Fatal("fail with unexpected error", err)
	}
	if len(nodes) != 0 {
		t.Fatal("nodes should not have items")
	}

}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:22,代码来源:mapper_test.go


示例15: TestCompleteEndnodeOnboardingMapper_restoringGateway

func TestCompleteEndnodeOnboardingMapper_restoringGateway(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	restoreStates := []state.State{state.WaitingRestore, state.Restoring}
	for _, s := range restoreStates {

		mapper.StateTable = &state.Table{
			Gateway: s,
			Apps: map[common.LocalID]state.State{
				common.LocalID(common.LocalAppID("jp", "app67890")): state.WaitingRestore,
			},
			RestoreMode: true,
		}
		err := mapper.CompleteEndnodeOnboarding("jp", "app67890", "T0001endnode", "th.0001endnode")
		if err == nil {
			t.Fatal("TestCompleteEndnodeOnboardingMapper_restoringGateway should fail")
		}
		if err.Error() != "state isn't expected one of WAITING_RESTORE nor RESTORING but actual: UNKNONWD_STATE" {
			t.Fatal("fail with other error", err)
		}
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:22,代码来源:mapper_test.go


示例16: TestGetGatewayIDMapper_restoringGateway

func TestGetGatewayIDMapper_restoringGateway(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()
	mapper.StateTable = &state.Table{
		Gateway: state.WaitingRestore,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.WaitingRestore,
		},
		RestoreMode: true,
	}
	id, err := mapper.GetGatewayID("jp", "app67890")
	if err == nil {
		t.Fatal("should fail")
	}

	if id != "" {
		t.Fatal("id should be empty")
	}
	if err.Error() != "state isn't expected one of WAITING_RESTORE nor RESTORING but actual: UNKNONWD_STATE" {
		t.Fatal("faild with other error", err)
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:22,代码来源:mapper_test.go


示例17: TestPendingEndnodesMapper_basic

// test PendingEndnodes
func TestPendingEndnodesMapper_basic(t *testing.T) {
	mapper := newMapper()
	mapper.StateTable = &state.Table{
		Gateway: state.DoneOnboard,
		Apps: map[common.LocalID]state.State{
			common.LocalID(common.LocalAppID("jp", "app67890")): state.DoneOnboard,
		},
	}
	defer mapper.clear()
	nodes, err := mapper.PendingEndnodes("jp", "app67890")
	if err != nil {
		t.Fatal("TestPendingEndnodesMapper_basic failed", err)
	}
	if mapper.store.serverLocation != "jp" {
		t.Error("ServerLocation should be \"en\":", mapper.store.serverLocation)
	}
	if mapper.store.appID != "app67890" {
		t.Error("AppID should be \"app67890\":", mapper.store.appID)
	}
	if len(nodes) != 2 {
		t.Error("number of pending nodes should be 2:", len(nodes))
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:24,代码来源:mapper_test.go


示例18: TestOnboardedEndnodesMapper_ENAppNotDoneOnboard

func TestOnboardedEndnodesMapper_ENAppNotDoneOnboard(t *testing.T) {
	mapper := newMapper()
	defer mapper.clear()

	restoreStates := []state.State{state.WaitingOnboard, state.Onboarding}
	for _, s := range restoreStates {
		mapper.StateTable = &state.Table{
			Gateway: state.DoneOnboard,
			Apps: map[common.LocalID]state.State{
				common.LocalID(common.LocalAppID("jp", "app67890")): s,
			},
		}
		nodes, err := mapper.OnboardedEndnodes("jp", "app67890")
		if err == nil {
			t.Fatal("should fail")
		}
		if err.Error() != "state is expected one of DONE_ONBOARD but actual: UNKNONWD_STATE" {
			t.Fatal("fail with unexpected error", err)
		}
		if len(nodes) != 0 {
			t.Fatal("nodes should not have items")
		}
	}
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:24,代码来源:mapper_test.go


示例19: OnboardGatewayApp

// OnboardGatewayApp onboards the Gateway for the Gateway App
func (m *Mapper) OnboardGatewayApp() (string, error) {
	// verify state
	if m.StateTable.RestoreMode {
		return "", state.ErrRestoringGateway
	}
	if err := m.StateTable.CheckGatewayState(state.Onboarding); err == nil {
		return "", state.ErrOnboarding
	}

	// start to onboard
	// change state to Onboarding before onboard
	if err := m.StateTable.ChangeGatewayState(state.Onboarding,
		common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID)); err != nil {
		return "", err
	}

	// change state of gateway app to onboarding before onboard
	gwLocalID := common.LocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID)
	if err := m.StateTable.ChangeAppState(state.Onboarding,
		common.LocalID(gwLocalID)); err != nil {
		return "", err
	}

	handleErr := func(err error) (string, error) {
		m.StateTable.ChangeGatewayState(state.WaitingOnboard, common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID))
		m.StateTable.ChangeAppState(state.Onboarding,
			common.LocalID(gwLocalID))
		return "", err
	}

	// for multiple onboard, need to delete gateway from DB first
	if _, err := m.Store.FindGatewayByAppID(m.Config.MasterApp.AppID); err == nil {

		// disconnect mqtt connection
		if err := m.Cloud.DisconnectMQTTClient(common.App{
			AppID:          m.Config.MasterApp.AppID,
			ServerLocation: m.Config.MasterApp.Site,
		}); err != nil {
			return handleErr(err)
		}

		// delete gateway
		if err := m.Store.DeleteGateway(m.Config.MasterApp.AppID); err != nil {
			return handleErr(err)
		}
	}

	gwID, err := m.onboardgatewayApp()
	if err != nil {
		return handleErr(err)
	}

	// change state of gateway app to DoneOnboard after onboard
	if err := m.StateTable.ChangeAppState(state.DoneOnboard, common.LocalID(gwLocalID)); err != nil {
		return handleErr(err)
	}

	// change state to DoneOnboard after onboard
	if err := m.StateTable.ChangeGatewayState(state.DoneOnboard,
		common.ToLocalAppID(m.Config.MasterApp.Site, m.Config.MasterApp.AppID)); err != nil {
		return handleErr(err)
	}

	return gwID, nil
}
开发者ID:KiiPlatform,项目名称:gateway-agent,代码行数:66,代码来源:mapper.go



注:本文中的github.com/KiiPlatform/gateway-agent/internal/common.LocalID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang common.App类代码示例发布时间:2022-05-23
下一篇:
Golang shadow.Application类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap