This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MAX_RETRY_COUNT = 3; | |
| @sources.Mysql() | |
| export class Account extends Process { | |
| public name: string; | |
| // plain text, just a demo | |
| public password: string; | |
| public retryCount: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @sources.Mysql() | |
| export class User extends Entity { | |
| public id: number; | |
| public name: string; | |
| public inviterId: number; | |
| public get inviter(): User { | |
| return this.scene.load(User, { id: this.inviterId }); | |
| } | |
| public get posts() { | |
| return this.scene.query(Post, { authorId: this.id }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE `User` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `name` varchar(255) NOT NULL, | |
| `inviterId` int(11) NULL, | |
| PRIMARY KEY (`id`) | |
| ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; | |
| CREATE TABLE `Post` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `title` varchar(255) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @sources.Scene | |
| export class FormDemo extends RootSectionModel { | |
| @constraint.min(1) | |
| public seatCount: number; | |
| @constraint.required | |
| public phoneNumber: string; | |
| public message: string = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class ListDemo extends RootSectionModel { | |
| public from: number = 1; | |
| public to: number = 9; | |
| public get filteredReservations() { | |
| return this.scene.query(Reservation_SeatInRange, { from: this.from, to: this.to }); | |
| } | |
| public get totalCount() { | |
| return this.filteredReservations.length; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.graalvm.polyglot.*; | |
| import java.lang.reflect.Array; | |
| import java.lang.reflect.Field; | |
| import java.util.Arrays; | |
| public class Main { | |
| public static void main(String[] args) throws Exception { | |
| try (Context context = Context.create("js")) { | |
| context.eval("js", "" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function some_important_business_process(a, b) | |
| result = a + b | |
| c = 3 | |
| result = result * c | |
| return result | |
| end | |
| result = some_important_business_process(1, 2) | |
| print(result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function some_important_business_process(a, b) | |
| result = a + b | |
| c = 3 | |
| result = result * c | |
| return result | |
| end | |
| result = some_important_business_process(1, 2) | |
| print(result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func ExampleUnboundedExecutor_Go_panic() { | |
| concurrent.HandlePanic = func(recovered interface{}, funcName string) { | |
| fmt.Println(funcName) | |
| } | |
| executor := concurrent.NewUnboundedExecutor() | |
| executor.Go(willPanic) | |
| time.Sleep(time.Second) | |
| // output: | |
| // github.com/modern-go/concurrent_test.willPanic | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // set a logger to show who is blocking | |
| concurrent.InfoLogger = log.New(os.Stdout, "", 0) | |
| executor := concurrent.NewUnboundedExecutor() | |
| executor.Go(func(ctx context.Context) { | |
| everyMillisecond := time.NewTicker(time.Millisecond) | |
| for { | |
| select { | |
| case <-ctx.Done(): | |
| // info log will be printed while we wait | |
| time.Sleep(time.Second) |