Пример #1
0
func NewSession(c echo.Context) Session {
	session := Session{}
	session.context = c
	session.start_time = time.Now()

	session.meta = utils.NewConcurrentMap()
	session.records = utils.NewConcurrentMap()

	if session.context.Request().Method() != "GET" {

		body_reader := session.context.Request().Body()
		decoder := json.NewDecoder(body_reader)
		decoder.UseNumber()
		var params interface{}
		err := decoder.Decode(&params)

		if err == nil {
			session.params = params.(map[string]interface{})
		} else {
			session.params = make(map[string]interface{})
		}
	}

	session.cache = make(map[string]interface{})

	session.CheckAuthentication()

	return session
}
Пример #2
0
func SpawnChildProcesses() {
	processes = utils.NewConcurrentMap()

	// Config JSON
	child_conf := config.Config{}
	deepcopier.Copy(&config.SharedConfig).To(&child_conf)

	child_conf.ChildProcesses = 0
	child_conf.MaxProcs = 1
	child_conf.IsChild = true

	for i := 0; i < config.SharedConfig.ChildProcesses; i++ {

		if child_conf.ReusePort == false {
			child_conf.ServerPort = config.SharedConfig.ServerPort + i
		}

		child_conf.ChildProcessId = strconv.Itoa(i)
		child_conf_json, _ := json.Marshal(child_conf)
		args := string(child_conf_json)

		go spawnChildProcess(i, config.SharedConfig.BinaryPath, args)
	}

	WaitForExit()
}
Пример #3
0
func (s *Session) CopySessionForBulkRequest(guid string) Session {
	session := Session{}
	session.start_time = time.Now()

	session.meta = utils.NewConcurrentMap()
	session.records = utils.NewConcurrentMap()

	requests := s.params["request"].(map[string]interface{})["requests"].([]interface{})
	for _, r := range requests {
		request := r.(map[string]interface{})
		if request["guid"].(string) == guid {
			session.params = request
		}
	}

	session.cache = s.cache

	session.AuthFailed = s.AuthFailed
	session.User = s.User

	return session
}