Skip to content

Commit

Permalink
fix: addons in dev test
Browse files Browse the repository at this point in the history
  • Loading branch information
leoadonia committed Oct 18, 2024
1 parent 888a918 commit cc0b338
Show file tree
Hide file tree
Showing 134 changed files with 2,025 additions and 1,070 deletions.
3 changes: 1 addition & 2 deletions tests/ten_runtime/integration/go/access_property_go/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ ten_package_test_prepare_app("access_property_go_app") {
replace_files_after_install_app = [
"access_property_go_app/manifest.json",
"access_property_go_app/property.json",
"access_property_go_app/ten_packages",
]

replace_files_after_install_all = [ "access_property_go_app/ten_packages/extension/default_extension_go/extension.go" ]

deps = [
"//core/src/ten_manager",
"//packages/core_apps/default_app_go:upload_default_app_go_to_server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": [
{
"type": "extension",
"name": "default_extension_go",
"name": "extension_a",
"version": "0.3.0-alpha"
},
{
Expand All @@ -11,4 +11,4 @@
"version": "0.3.0-alpha"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,6 @@ func (p *aExtension) OnCmd(
}
}

type nodeTestGroup struct {
ten.DefaultExtensionGroup
}

func newNodeTestGroup(name string) ten.ExtensionGroup {
return &nodeTestGroup{}
}

func (p *nodeTestGroup) OnCreateExtensions(
tenEnv ten.TenEnv,
) {
tenEnv.OnCreateExtensionsDone(
ten.WrapExtension(&aExtension{}, "A"),
)
}

func init() {
// Register addon
err := ten.RegisterAddonAsExtension(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module extension_a

go 1.18

replace ten_framework => ../../../ten_packages/system/ten_runtime_go/interface

require ten_framework v0.0.0-00010101000000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "extension",
"name": "extension_a",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.3.0-alpha"
}
],
"package": {
"include": [
"**"
]
},
"api": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 3 additions & 2 deletions tests/ten_runtime/integration/go/expired_ten_go/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ ten_package_test_prepare_app("expired_ten_go_app") {
replace_files_after_install_app = [
"expired_ten_go_app/manifest.json",
"expired_ten_go_app/property.json",
"expired_ten_go_app/ten_packages",
"expired_ten_go_app/go_common_dep",
"expired_ten_go_app/go.mod",
]

replace_files_after_install_all = [ "expired_ten_go_app/ten_packages/extension/default_extension_go/extension.go" ]

if (ten_enable_package_manager) {
deps = [
"//core/src/ten_manager",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module app

go 1.20

replace ten_framework => ./ten_packages/system/ten_runtime_go/interface

replace go_common_dep => ./go_common_dep

require ten_framework v0.0.0-00010101000000-000000000000

require go_common_dep v0.0.0-00010101000000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go_common_dep

go 1.18
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package types

type UserData struct {
Uid int
Name string
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"dependencies": [
{
"type": "extension",
"name": "default_extension_go",
"name": "extension_a",
"version": "0.3.0-alpha"
},
{
"type": "extension",
"name": "extension_b",
"version": "0.3.0-alpha"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,18 @@ import (
"fmt"
"time"

"go_common_dep/types"
"ten_framework/ten"
)

type extensionA struct {
ten.DefaultExtension
}

type extensionB struct {
ten.DefaultExtension
}

func newExtensionA(name string) ten.Extension {
return &extensionA{}
}

func newExtensionB(name string) ten.Extension {
return &extensionB{}
}

func (p *extensionA) OnCmd(
tenEnv ten.TenEnv,
cmd ten.Cmd,
Expand All @@ -47,7 +40,7 @@ func (p *extensionA) OnCmd(
tenEnv.ReturnResult(cmdResult, cmd)
} else {
cmdResult, _ := ten.NewCmdResult(ten.StatusCodeOk)
cmdResult.SetPropertyString("detail", detail.(*userData).name)
cmdResult.SetPropertyString("detail", detail.(*types.UserData).Name)
tenEnv.ReturnResult(cmdResult, cmd)
}
})
Expand All @@ -63,31 +56,6 @@ func (p *extensionA) OnCmd(
}()
}

type userData struct {
uid int
name string
}

func (p *extensionB) OnCmd(
tenEnv ten.TenEnv,
cmd ten.Cmd,
) {
go func() {
fmt.Println("extensionB OnCmd")

cmdName, _ := cmd.GetName()
if cmdName == "B" {
data := userData{uid: 1, name: "ten"}
cs, _ := ten.NewCmdResult(ten.StatusCodeOk)
cs.SetProperty("data", &data)
err := tenEnv.ReturnResult(cs, cmd)
if err != nil {
panic(err)
}
}
}()
}

func init() {
// Register addon
err := ten.RegisterAddonAsExtension(
Expand All @@ -97,12 +65,4 @@ func init() {
if err != nil {
fmt.Println("register addon failed", err)
}

err = ten.RegisterAddonAsExtension(
"extension_b",
ten.NewDefaultExtensionAddon(newExtensionB),
)
if err != nil {
fmt.Println("register addon failed", err)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module extension_a

go 1.18

replace ten_framework => ../../../ten_packages/system/ten_runtime_go/interface

replace go_common_dep => ../../../go_common_dep

require ten_framework v0.0.0-00010101000000-000000000000

require go_common_dep v0.0.0-00010101000000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "extension",
"name": "extension_a",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.3.0-alpha"
}
],
"package": {
"include": [
"**"
]
},
"api": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Copyright © 2024 Agora
// This file is part of TEN Framework, an open source project.
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to https://github.com/TEN-framework/ten_framework/LICENSE for more
// information.
//

package default_extension_go

import (
"fmt"

"go_common_dep/types"
"ten_framework/ten"
)

type extensionB struct {
ten.DefaultExtension
}

func newExtensionB(name string) ten.Extension {
return &extensionB{}
}

func (p *extensionB) OnCmd(
tenEnv ten.TenEnv,
cmd ten.Cmd,
) {
go func() {
fmt.Println("extensionB OnCmd")

cmdName, _ := cmd.GetName()
if cmdName == "B" {
data := types.UserData{Uid: 1, Name: "ten"}
cs, _ := ten.NewCmdResult(ten.StatusCodeOk)
cs.SetProperty("data", &data)
err := tenEnv.ReturnResult(cs, cmd)
if err != nil {
panic(err)
}
}
}()
}

func init() {
// Register addon
err := ten.RegisterAddonAsExtension(
"extension_b",
ten.NewDefaultExtensionAddon(newExtensionB),
)
if err != nil {
fmt.Println("register addon failed", err)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module extension_b

go 1.18

replace ten_framework => ../../../ten_packages/system/ten_runtime_go/interface

replace go_common_dep => ../../../go_common_dep

require ten_framework v0.0.0-00010101000000-000000000000

require go_common_dep v0.0.0-00010101000000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "extension",
"name": "extension_b",
"version": "0.3.0-alpha",
"dependencies": [
{
"type": "system",
"name": "ten_runtime_go",
"version": "0.3.0-alpha"
}
],
"package": {
"include": [
"**"
]
},
"api": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ ten_package_test_prepare_app("frequently_cgo_call_go_app") {
replace_files_after_install_app = [
"frequently_cgo_call_go_app/manifest.json",
"frequently_cgo_call_go_app/property.json",
"frequently_cgo_call_go_app/ten_packages",
]

replace_files_after_install_all = [ "frequently_cgo_call_go_app/ten_packages/extension/default_extension_go/extension.go" ]

if (ten_enable_package_manager) {
deps = [
"//core/src/ten_manager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"dependencies": [
{
"type": "extension",
"name": "default_extension_go",
"name": "extension_a",
"version": "0.3.0-alpha"
},
{
"type": "extension",
"name": "extension_b",
"version": "0.3.0-alpha"
},
{
Expand Down
Loading

0 comments on commit cc0b338

Please sign in to comment.