本文整理匯總了Golang中github.com/flynn/flynn/pkg/postgres.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetUpSuite
func (s *S) SetUpSuite(c *C) {
s.discoverd, s.cleanup = setup(c)
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
pgxConfig := newPgxConnPoolConfig()
pgxpool, err := pgx.NewConnPool(pgxConfig)
if err != nil {
c.Fatal(err)
}
db := postgres.New(pgxpool, nil)
if err = migrateDB(db); err != nil {
c.Fatal(err)
}
db.Close()
// reconnect with prepared statements
pgxConfig.AfterConnect = schema.PrepareStatements
pgxpool, err = pgx.NewConnPool(pgxConfig)
if err != nil {
c.Fatal(err)
}
db = postgres.New(pgxpool, nil)
s.pgx = db.ConnPool
s.pgx.Exec(sqlCreateTruncateTables)
}
示例2: SetUpSuite
func (s *S) SetUpSuite(c *C) {
dbname := "controllertest"
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: os.Getenv("PGHOST"),
Database: dbname,
},
})
if err != nil {
c.Fatal(err)
}
db := postgres.New(pgxpool, nil)
if err = migrateDB(db); err != nil {
c.Fatal(err)
}
// reconnect with que statements prepared now that schema is migrated
pgxpool, err = pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: "/var/run/postgresql",
Database: dbname,
},
AfterConnect: schema.PrepareStatements,
})
if err != nil {
c.Fatal(err)
}
db = postgres.New(pgxpool, nil)
s.flac = newFakeLogAggregatorClient()
s.cc = tu.NewFakeCluster()
s.hc = handlerConfig{
db: db,
cc: s.cc,
lc: s.flac,
rc: newFakeRouter(),
keys: []string{authKey},
}
handler := appHandler(s.hc)
s.srv = httptest.NewServer(handler)
client, err := controller.NewClient(s.srv.URL, authKey)
c.Assert(err, IsNil)
s.c = client
}
示例3: TestPostgresFilesystem
func TestPostgresFilesystem(t *testing.T) {
dbname := "blobstoretest"
if err := pgtestutils.SetupPostgres(dbname); err != nil {
t.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: os.Getenv("PGHOST"),
Database: dbname,
},
})
if err != nil {
t.Fatal(err)
}
db := postgres.New(pgxpool, nil)
defer db.Close()
fs, err := NewPostgresFilesystem(db)
if err != nil {
t.Fatal(err)
}
testList(fs, t)
testDelete(fs, t)
testOffset(fs, t)
testFilesystem(fs, true, t)
}
示例4: setupTestDB
func setupTestDB(c *C, dbname string) *postgres.DB {
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: os.Getenv("PGHOST"),
Database: dbname,
},
})
if err != nil {
c.Fatal(err)
}
return postgres.New(pgxpool, nil)
}
示例5: SetUpSuite
func (s *S) SetUpSuite(c *C) {
s.discoverd, s.cleanup = setup(c)
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(newPgxConnPoolConfig())
if err != nil {
c.Fatal(err)
}
db := postgres.New(pgxpool, nil)
if err = migrateDB(db); err != nil {
c.Fatal(err)
}
s.pgx = db.ConnPool
s.pgx.Exec(sqlCreateTruncateTables)
}
示例6: createDB
func createDB(t *testing.T, dbname string) *postgres.DB {
if dbname == "" {
dbname = "blobstoretest"
}
if err := pgtestutils.SetupPostgres(dbname); err != nil {
t.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: os.Getenv("PGHOST"),
Database: dbname,
},
})
if err != nil {
t.Fatal(err)
}
db := postgres.New(pgxpool, nil)
return db
}
示例7: SetUpSuite
func (s *S) SetUpSuite(c *C) {
dbname := "controllertest"
db := setupTestDB(c, dbname)
if err := migrateDB(db); err != nil {
c.Fatal(err)
}
// reconnect with que statements prepared now that schema is migrated
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: "/var/run/postgresql",
Database: dbname,
},
AfterConnect: schema.PrepareStatements,
})
if err != nil {
c.Fatal(err)
}
db = postgres.New(pgxpool, nil)
ca, err := certgen.Generate(certgen.Params{IsCA: true})
if err != nil {
c.Fatal(err)
}
s.caCert = []byte(ca.PEM)
s.flac = newFakeLogAggregatorClient()
s.cc = tu.NewFakeCluster()
s.hc = handlerConfig{
db: db,
cc: s.cc,
lc: s.flac,
rc: newFakeRouter(),
keys: []string{authKey},
caCert: s.caCert,
}
handler := appHandler(s.hc)
s.srv = httptest.NewServer(handler)
client, err := controller.NewClient(s.srv.URL, authKey)
c.Assert(err, IsNil)
s.c = client
}
示例8: SetUpSuite
func (s *S) SetUpSuite(c *C) {
dbname := "controllertest"
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
dsn := fmt.Sprintf("dbname=%s", dbname)
db, err := sql.Open("postgres", dsn)
if err != nil {
c.Fatal(err)
}
if err = migrateDB(db); err != nil {
c.Fatal(err)
}
pg := postgres.New(db, dsn)
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: "/var/run/postgresql",
Database: dbname,
},
AfterConnect: que.PrepareStatements,
})
if err != nil {
c.Fatal(err)
}
s.flac = newFakeLogAggregatorClient()
s.cc = tu.NewFakeCluster()
s.hc = handlerConfig{
db: pg,
cc: s.cc,
lc: s.flac,
rc: newFakeRouter(),
pgxpool: pgxpool,
keys: []string{authKey},
}
handler := appHandler(s.hc)
s.srv = httptest.NewServer(handler)
client, err := controller.NewClient(s.srv.URL, authKey)
c.Assert(err, IsNil)
s.c = client
}
示例9: SetUpSuite
func (s *S) SetUpSuite(c *C) {
s.discoverd, s.cleanup = setup(c)
dbname := "routertest"
if err := pgtestutils.SetupPostgres(dbname); err != nil {
c.Fatal(err)
}
pgxpool, err := pgx.NewConnPool(pgx.ConnPoolConfig{
ConnConfig: pgx.ConnConfig{
Host: os.Getenv("PGHOST"),
Database: dbname,
},
})
if err != nil {
c.Fatal(err)
}
db := postgres.New(pgxpool, nil)
if err = migrateDB(db); err != nil {
c.Fatal(err)
}
s.pgx = db.ConnPool
s.pgx.Exec(sqlCreateTruncateTables)
}