本文整理汇总了Golang中github.com/concourse/atc/db.NewSQL函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSQL函数的具体用法?Golang NewSQL怎么用?Golang NewSQL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSQL函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: constructDB
func (cmd *ATCCommand) constructDB(logger lager.Logger) (*db.SQLDB, db.PipelineDBFactory, error) {
dbConn, err := migrations.LockDBAndMigrate(logger.Session("db.migrations"), "postgres", cmd.PostgresDataSource)
if err != nil {
return nil, nil, fmt.Errorf("failed to migrate database: %s", err)
}
listener := pq.NewListener(cmd.PostgresDataSource, time.Second, time.Minute, nil)
bus := db.NewNotificationsBus(listener, dbConn)
explainDBConn := db.Explain(logger, dbConn, clock.NewClock(), 500*time.Millisecond)
sqlDB := db.NewSQL(logger.Session("db"), explainDBConn, bus)
pipelineDBFactory := db.NewPipelineDBFactory(logger.Session("db"), explainDBConn, bus, sqlDB)
return sqlDB, pipelineDBFactory, err
}
开发者ID:ACPK,项目名称:atc,代码行数:16,代码来源:command.go
示例2:
"github.com/concourse/atc/event"
)
var _ = Describe("One-off Builds", func() {
var atcProcess ifrit.Process
var dbListener *pq.Listener
var atcPort uint16
var pipelineDBFactory db.PipelineDBFactory
BeforeEach(func() {
dbLogger := lagertest.NewTestLogger("test")
postgresRunner.Truncate()
dbConn = postgresRunner.Open()
dbListener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
bus := db.NewNotificationsBus(dbListener, dbConn)
sqlDB = db.NewSQL(dbLogger, dbConn, bus)
pipelineDBFactory = db.NewPipelineDBFactory(dbLogger, dbConn, bus, sqlDB)
atcProcess, atcPort = startATC(atcBin, 1)
})
AfterEach(func() {
ginkgomon.Interrupt(atcProcess)
Expect(dbConn.Close()).To(Succeed())
Expect(dbListener.Close()).To(Succeed())
})
Describe("viewing a list of builds", func() {
var page *agouti.Page
var pipelineDB db.PipelineDB
开发者ID:ACPK,项目名称:atc,代码行数:31,代码来源:builds_list_test.go
示例3:
"github.com/concourse/atc"
"github.com/concourse/atc/db"
)
var _ = Describe("Auth", func() {
var atcProcess ifrit.Process
var dbListener *pq.Listener
var atcPort uint16
BeforeEach(func() {
logger := lagertest.NewTestLogger("test")
postgresRunner.CreateTestDB()
dbConn = postgresRunner.Open()
dbListener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
bus := db.NewNotificationsBus(dbListener)
sqlDB = db.NewSQL(logger, dbConn, bus)
_, err := sqlDB.SaveConfig(atc.DefaultPipelineName, atc.Config{}, db.ConfigVersion(1), db.PipelineUnpaused)
Ω(err).ShouldNot(HaveOccurred())
atcBin, err := gexec.Build("github.com/concourse/atc/cmd/atc")
Ω(err).ShouldNot(HaveOccurred())
atcPort = 5697 + uint16(GinkgoParallelNode())
debugPort := 6697 + uint16(GinkgoParallelNode())
atcCommand := exec.Command(
atcBin,
"-webListenPort", fmt.Sprintf("%d", atcPort),
"-debugListenPort", fmt.Sprintf("%d", debugPort),
"-httpUsername", "admin",
开发者ID:utako,项目名称:atc,代码行数:31,代码来源:auth_test.go
示例4:
var _ = Describe("SQL DB Teams", func() {
var dbConn db.Conn
var listener *pq.Listener
var database db.DB
BeforeEach(func() {
postgresRunner.Truncate()
dbConn = db.Wrap(postgresRunner.Open())
listener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
Eventually(listener.Ping, 5*time.Second).ShouldNot(HaveOccurred())
bus := db.NewNotificationsBus(listener, dbConn)
database = db.NewSQL(lagertest.NewTestLogger("test"), dbConn, bus)
database.DeleteTeamByName(atc.DefaultTeamName)
})
AfterEach(func() {
err := dbConn.Close()
Expect(err).NotTo(HaveOccurred())
err = listener.Close()
Expect(err).NotTo(HaveOccurred())
})
Describe("the default team", func() {
Describe("it exists", func() {
BeforeEach(func() {
开发者ID:pcfdev-forks,项目名称:atc,代码行数:31,代码来源:db_teams_test.go
示例5:
var pipelineDBFactory db.PipelineDBFactory
var sqlDB *db.SQLDB
var pipelineDB db.PipelineDB
var otherPipelineDB db.PipelineDB
BeforeEach(func() {
postgresRunner.Truncate()
dbConn = postgresRunner.Open()
listener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
Eventually(listener.Ping, 5*time.Second).ShouldNot(HaveOccurred())
bus := db.NewNotificationsBus(listener, dbConn)
sqlDB = db.NewSQL(lagertest.NewTestLogger("test"), dbConn, bus)
pipelineDBFactory = db.NewPipelineDBFactory(lagertest.NewTestLogger("test"), dbConn, bus, sqlDB)
_, err := sqlDB.SaveConfig("a-pipeline-name", atc.Config{}, 0, db.PipelineUnpaused)
Expect(err).NotTo(HaveOccurred())
pipelineDB, err = pipelineDBFactory.BuildWithName("a-pipeline-name")
Expect(err).NotTo(HaveOccurred())
_, err = sqlDB.SaveConfig("another-pipeline", atc.Config{}, 0, db.PipelineUnpaused)
Expect(err).NotTo(HaveOccurred())
otherPipelineDB, err = pipelineDBFactory.BuildWithName("another-pipeline")
Expect(err).NotTo(HaveOccurred())
})
开发者ID:ACPK,项目名称:atc,代码行数:29,代码来源:pipeline_db_resource_versions_test.go
示例6: main
func main() {
flag.Parse()
if !*dev && (*httpUsername == "" || (*httpHashedPassword == "" && *httpPassword == "")) {
fatal(errors.New("must specify -httpUsername and -httpPassword or -httpHashedPassword or turn on dev mode"))
}
if _, err := os.Stat(*templatesDir); err != nil {
fatal(errors.New("directory specified via -templates does not exist"))
}
if _, err := os.Stat(*publicDir); err != nil {
fatal(errors.New("directory specified via -public does not exist"))
}
logger := lager.NewLogger("atc")
logLevel := lager.INFO
if *dev {
logLevel = lager.DEBUG
}
sink := lager.NewReconfigurableSink(lager.NewWriterSink(os.Stdout, lager.DEBUG), logLevel)
logger.RegisterSink(sink)
var err error
var dbConn Db.Conn
for {
dbConn, err = migration.Open(*sqlDriver, *sqlDataSource, migrations.Migrations)
if err != nil {
if strings.Contains(err.Error(), " dial ") {
logger.Error("failed-to-open-db", err)
time.Sleep(5 * time.Second)
continue
}
fatal(err)
}
break
}
dbConn = Db.Explain(logger, dbConn, 500*time.Millisecond)
listener := pq.NewListener(*sqlDataSource, time.Second, time.Minute, nil)
bus := Db.NewNotificationsBus(listener)
db := Db.NewSQL(logger.Session("db"), dbConn, bus)
pipelineDBFactory := Db.NewPipelineDBFactory(logger.Session("db"), dbConn, bus, db)
var configDB Db.ConfigDB
configDB = Db.PlanConvertingConfigDB{db}
var resourceTypesNG []atc.WorkerResourceType
err = json.Unmarshal([]byte(*resourceTypes), &resourceTypesNG)
if err != nil {
logger.Fatal("invalid-resource-types", err)
}
var workerClient worker.Client
if *gardenAddr != "" {
workerClient = worker.NewGardenWorker(
gclient.New(gconn.NewWithLogger(
*gardenNetwork,
*gardenAddr,
logger.Session("garden-connection"),
)),
clock.NewClock(),
-1,
resourceTypesNG,
"linux",
[]string{},
)
} else {
workerClient = worker.NewPool(worker.NewDBWorkerProvider(db, logger))
}
resourceTracker := resource.NewTracker(workerClient)
gardenFactory := exec.NewGardenFactory(workerClient, resourceTracker, func() string {
guid, err := uuid.NewV4()
if err != nil {
panic("not enough entropy to generate guid: " + err.Error())
}
return guid.String()
})
execEngine := engine.NewExecEngine(gardenFactory, engine.NewBuildDelegateFactory(db), db)
engine := engine.NewDBEngine(engine.Engines{execEngine}, db, db)
var webValidator auth.Validator
if *httpUsername != "" && *httpHashedPassword != "" {
webValidator = auth.BasicAuthHashedValidator{
Username: *httpUsername,
HashedPassword: *httpHashedPassword,
}
} else if *httpUsername != "" && *httpPassword != "" {
//.........这里部分代码省略.........
开发者ID:utako,项目名称:atc,代码行数:101,代码来源:main.go
注:本文中的github.com/concourse/atc/db.NewSQL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论