package main

import (
	"context"
	"fmt"
	"log"
	"training/domain"
	"training/tracking"
)

func main() {
	ctx := context.Background()

	ctx = setContext(ctx)

	getContext(ctx)

}

func setContext(ctx context.Context) context.Context {
	u := domain.User{ID: 10, Name: "Rob"}
	ctx = domain.WithContext(ctx, &u)

	tracer := tracking.Tracer{ID: 20}
	ctx = tracking.WithContext(ctx, &tracer)

	return ctx
}

func getContext(ctx context.Context) {
	u, err := domain.FromContext(ctx)
	if err != nil {
		log.Println(err)
	}
	fmt.Println("user:", u)

	t, err := tracking.FromContext(ctx)
	if err != nil {
		log.Println(err)
	}
	fmt.Println("tracer:", t)
}
